#P1969. [NOIP 2013 提高组] 积木大赛
[NOIP 2013 提高组] 积木大赛
Description
Chun-Chun Kindergarten is holding its annual "Building Blocks Contest." This year, the task is to construct a building of width , which can be regarded as composed of blocks each of width . The final height of the -th block should be .
Before construction starts, there are no blocks (equivalently, there are blocks of height ). In each operation, the children may choose a continuous interval , and then increase by the height of every block from the -th to the -th (inclusive).
Xiao M is a clever child and quickly figured out an optimal strategy that minimizes the number of operations. However, she is not keen on doing it herself, so she asks you to implement this strategy and compute the minimum number of operations.
Input Format
There are two lines. The first line contains an integer , the width of the building.
The second line contains integers, where the -th integer is .
Output Format
Output the minimum number of operations required to complete the construction.
5
2 3 4 1 2
5
Hint
Sample explanation:
One optimal sequence is to choose: , , , , .
Constraints:
- For of the testdata, .
- For of the testdata, .
- For of the testdata, , .
Translated by ChatGPT 5
京公网安备 11011102002149号