Time limit 2000/4000/4000/4000 ms. Memory limit 65000/65000/65000/65000 Kb. Question by Ibrahim Mesecan.
Jump Min Value
Tommy and his friends are playing a game. In the game,
there is a series of random numbers. And, they want to start
from the beginning and reach to the end while jumping
over at most one consecutive number. For example if there is a
number series: 2 3 4 5 , it is possible
jump over 2 and 4 (image 2 on the right JMV=8),
or 3 and 5 (image 1 on the right with JMV=6).
But, not 2 and 3 (image 3) or 4
and 5 (image 4) (no two consecutive numbers). It is also
possible not to jump and continue to the next number.
Question: Write a program that reads
a number series and decides the min jump value.
Input specification:
You will be given an integer in the first line (n) number of
numbers. In the second line you will be given a (n) positive
integers where 1 ≤ n ≤ 30.
Output specification:
Show one integer: min jump value.
Sample Input 1 |
Sample Input 2 |
4
2 3 4 5
|
6
9 6 19 13 3 14
|
Sample Output 1 |
Sample Output 2 |
6
|
22
|
Explanation for sample input 2:
Tommy can jump over 9 and 19
and 14 .
Thus he steps on 6 + 13 + 3 = 22 .
Для отправки решений необходимо выполнить вход.
|