HomeVolumesContestsSectionsForumsUsersPrintHelpAbout

Contests > CEN254 Final Exam > problem:


1. 51142 - Jump Min Value

CEN254 Final Exam

Start: June.23.2017 at 12:25:00 PM
Finish: June.23.2017 at 01:25:00 PM
The contest is finished!
• Contest scoreboard

Contest problems

• 1. 51142 - Jump Min Value
• 2. 51143 - Departments Competition
• 3. 51082 - Sum is equal to K - 1
• 4. 51145 - Graduation Exam

Feedback

If you notice incorrect translations in Contester, please let author know.

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.



Для отправки решений необходимо выполнить вход.

www.contester.ru