Problem G
Scaffolding

As a construction worker, you want to build a bamboo
scaffold for an upcoming festival. There are specific
requirements for the final scaffold, which will be part of a
vertical,
![\includegraphics[width=.95\textwidth ]{diagrams}](/problems/scaffolding/file/statement/en/img-0002.png)
You can carry at most
You can only stand on a short bamboo that was built previously (or on ground level). Then you have two options:
-
Climb left, right or up if a short bamboo is already in place there
-
Place a short bamboo to the left, right or up if there is no short bamboo already placed
Note that you cannot go down while carrying short bamboos. You cannot place a short bamboo below you either.
Once you finish placing all the short bamboos in the current
round, you go down to the ground level. You then take at most
What is the minimum number of rounds you need?
Input
The first line contains two integers,
Output
Output an integer representing the minimum number of rounds.
Sample Input 1 | Sample Output 1 |
---|---|
3 4 2 1 5 |
2 |
Sample Input 2 | Sample Output 2 |
---|---|
5 10 2 1 2 1 2 |
3 |