P2816 Song Rongzi Builds Blocks
Description
saruka loves building with blocks and has $n$ 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 $i$-th block has a mood value $x_i$. If the total number of blocks stacked on top of this block exceeds $x_i$, 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 $n$, as described above.
The second line contains $n$ numbers $x_i$, as described above.
Output Format
Output a single integer, the minimum number of columns.
Explanation/Hint
For $100\%$ of the testdata, $1 \le n \le 5000$, $0 \le x_i \le n$.
Translated by ChatGPT 5