HomeVolumesContestsSectionsForumsUsersPrintHelpAbout

Sections > Exhaustive search & Backtracking > problem:


51142 - Jump Min Value

Section problems

• 50479 - Bit Compressor
• 50486 - Problems and Programmers
• 50712 - Moon algebra
• 50717 - Hurdle Jumping
• 50840 - Tanker trucks
• 50490 - Across the River
• 50828 - Arranging Time Table
• 51067 - Jumping frog
• 51142 - Jump Min Value
• 51082 - Sum is equal to K - 1
• Post Office Delivery
• 50506 - The Biggest Island
• 50718 - Elevator
• 50593 - Transporter
• 50600 - Expression
• 50720 - Permutations (2)

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