Problem C
Don't Fall Down Stairs

King Whomp is walking down Whomp Fortress to fight Mario. In
order to get down, he must descend down a staircase consisting
of
However, King Whomp is injured these days, so he cannot walk
down steps that have a height difference of more than
Every brick that the Whomps add or remove costs one unit of effort for them. Can you help them calculate the minimum amount of effort needed to help King Whomp walk from Whomp Fortress to Mario, who is on the ground at height 0?
Input
The first line of the input is an integer
The second line of input contains
Output
Output one line containing a single integer
Sample Input 1 | Sample Output 1 |
---|---|
5 9 7 5 4 4 |
5 |
Sample Input 2 | Sample Output 2 |
---|---|
4 5 4 3 2 |
1 |