#P2816. 宋荣子搭积木
宋荣子搭积木
Description
saruka loves building with blocks and has blocks. saruka’s blocks are special: they can only be stacked vertically one by one, and you may build many columns. Since saruka’s blocks are special, they are intelligent. The -th block has a mood value . If the total number of blocks stacked on top of this block exceeds , this block will be unhappy and vows never to play with saruka again. saruka loves blocks and will not make any block unhappy, but saruka also wants to use every block and minimize the number of columns. Can you help saruka?
Input Format
The first line contains an integer , as described above.
The second line contains numbers , as described above.
Output Format
Output a single integer, the minimum number of columns.
3
0 0 3
2
4
0 0 0 0
4
Hint
For of the testdata, , .
Translated by ChatGPT 5
京公网安备 11011102002149号