-->
当前位置:首页 > 题库

PROGRAMMING:Frog across the bridge

Luz5年前 (2021-05-10)题库460
A bridge of length N, the coordinate of one end of the starting point is 0, and there are a [i] stones [0 < = a [i] < = 4] at the integer coordinate I,
A frog starts to jump from the coordinate 0, and the distance of one step is 1 or 2 or 3,
When the frog falls at I, it will step on all the stones at that point. How many stones can the frog step on at least? And the output jumps in turn
If there are multiple routes, the one with the smallest dictionary order will be output.
###Input format:
The first line is integer n (< 150000), and then the next line will have n + 1 integers separated by spaces, that is, the number of stones at each coordinate on the bridge.
###Output format:
The first step is to step on the least number of stones, and the second step is to skip the coordinate points in turn.
###Input example:
Two sets of inputs are given here. For example:
```in
ten
1 2 1 3 0 3 1 2 1 1 2
```
```in
one hundred
1 2 0 4 0 1 3 4 2 2 1 3 1 4 0 3 0 1 2 3 3 2 2 0 1 0 0 0 0 1 2 1 3 4 0 3 4 4 1 0
4 1 3 1 1 2 3 4 4 4 0 2 0 1 1 1 3 1 3 2 1 2 4 1 2 1 4 1 0 0 1 2 3 0 2 4 4 0 0 4
2 0 0 2 1 3 3 3 0 0 2 0 0 1 2 4 2 2 2 4 0
```
###Output example:
The corresponding output is given here. For example:
```out
four
0 2 4 6 8
```
```out
thirty-six
0 2 4 5 8 10 12 14 16 17 20 23 25 26 27 28 31 34 35 38 39 41 44 47 50 52 54 57 60 63 65 68 69 70 73 74 77 78 81 82 85 88 89 91 92 94 97 100
```







answer:If there is no answer, please comment