#P16597. [SYSUCPC 2025] Abacus
[SYSUCPC 2025] Abacus
题目描述
There is a special abacus lying flat on the table with a total of vertical rods. Each vertical rod has some beads, forming a total of rows. The -th row from the top contains beads, where is a positive integer not exceeding . Adjacent rows on a vertical rod may not necessarily both have beads. Now, the abacus is stood upright, and all beads fall naturally. Determine the number of beads in each row after the beads have fallen. It can be proved that there are still rows after the beads fall.
The process for the first sample case is as follows:
:::align{center}
:::
输入格式
The first line contains two integers and .
The next line contains integers . It is guaranteed that for all .
输出格式
The only line contains integers represent the beads in each row after the process.
4 6
4 2 6 3
2 3 4 6
7 10
3 6 6 4 3 1 5
1 3 3 4 5 6 6