#P16597. [SYSUCPC 2025] Abacus

    ID: 16366 Type: RemoteJudge 2000ms 128MiB Tried: 0 Accepted: 0 Difficulty: 3 Uploaded By: Tags>模拟2025排序高校校赛

[SYSUCPC 2025] Abacus

题目描述

There is a special abacus lying flat on the table with a total of mm vertical rods. Each vertical rod has some beads, forming a total of nn rows. The ii-th row from the top contains aia_i beads, where aia_i is a positive integer not exceeding mm. 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 nn rows after the beads fall.

The process for the first sample case is as follows:

:::align{center} :::

输入格式

The first line contains two integers nn and m(1n,m104)m(1\le n,m\le 10^4).

The next line contains nn integers a1,a2,,ana_1,a_2,\dots,a_n. It is guaranteed that 1aim1\le a_i\le m for all i=1,2,,ni=1,2,\dots,n.

输出格式

The only line contains nn 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