Problemas
Bessie is planning an infinite adventure in a land with
Bessie has
Entrada
The first line contains two space-separated integers:
The second line contains
For
For
Salida
Print
Subtarea
| # | Puntaje | Condición |
|---|---|---|
| #1 | 25 | |
| #2 | 25 | |
| #3 | 25 | |
| #4 | 25 | 추가 제약 조건 없음 |
Ejemplo #1
5 4
1 2 1 2 8
2
3 4
4
2 3
5 5 5 5 5 1 5 5
2 4 3
3 3 6
5 3 2
5 3 7
2
2
5
4
Bessie's first three adventures proceed as follows:
In the first adventure, she goes from city
2 at time4 to city3 at time5 , to city4 at time6 , to city2 at time7 .In the second adventure, she goes from city
3 at time3 to city4 at time4 , to city2 at time5 , to city4 at time6 , to city2 at time7 , to city4 at time8 , to city2 at time9 .In the third adventure, she goes from city
5 at time3 to city5 at time4 , to city5 at time5 .
Ejemplo #2
5 5
1 2 1 2 8
2
3 4
4
2 3
5 5 5 5 5 1 5 5
2 4 3
3 2 6
5 3 2
5 3 7
5 3 1000000000000000000
2
3
5
4
2