Mincost Walk
Time: 1.0 s Memory: 1024 MB
-
You stumble upon a long sidewalk of square stones, each with a number written on it. You start on the leftmost stone and want to reach the rightmost stone.You come up with a game with yourself: you need to walk to the end of the sidewalk, taking only steps of length $1$ or $2$, trying to get as low of a sum as possible in the end as possible.
In total there are $N$ stones, each with a random number between $1$ and $100$.
Input
The first line of the input contains an integer $N$ ($1 \le N \le 10000$).
The next line contains $N$ integers $a_1, a_2, \ldots , a_N$ ($1 \le a_i \le 100$) where $a_i$ is the number written on the $i$-th stone.
Output
Output the minimum sum you can get by walking from the first stone to the last stone.
Sample Input 1 Sample Output 1 5 1 2 2 5 1
4
Sample Input 2 Sample Output 2 1 10
10
-
To solve the problems, you can either start a virtual contest or register for regular practice. A virtual contest simulates a participation in the original contest with a duration of 1 day, while regular practice lets you submit solutions without any constraints.
You must log in to register. - A Mincost Walk
- B Step Ways