luogu#P4364. [九省联考 2018] IIIDX
[九省联考 2018] IIIDX
Background
Have you heard of Osu? That is Konano’s favorite rhythm game, and his dream is to make a unique and cool music game of his own someday. Now he works at the world-renowned game company KONMAI, getting closer to his dream.
A music game usually contains many songs; the more songs, the less likely players get bored. Meanwhile, to make players spend more money more time on the game, not all tracks are available from the beginning. Some tracks are unlocked only after you clear a specific track, and the later a track is unlocked, the higher its difficulty tends to be.
Problem Description
Konano received a task to arrange the unlock order of tracks for the in-development game “IIIDX.” There are tracks in total. Each track has a difficulty . The -th track is unlocked after the player clears the -th track ( is the floor function). If , then this track requires no unlock.
For example, when , the -st track requires no unlock (), and the -th track is unlocked after the player clears the -rd track since .
Konano’s job is to arrange the order of these tracks so that each newly unlocked track has a difficulty not lower than the prerequisite track’s difficulty. That is, after determining the order, the difficulties satisfy for every .
Of course, this is easy for Konano, who has spent a lot of time “chilling” in informatics competitions. If it were you, how would you solve this task?
Input Format
The first line contains one positive integer and one real number . is the number of tracks, and is as described above.
The second line contains space-separated positive integers , representing the difficulties of the tracks.
Output Format
Output one line with integers: the difficulty of the -th track after arranging the order.
If there are multiple valid solutions, output the one with maximized; if still tied, maximize ; and so on.
4 2.0
114 514 1919 810
114 810 514 1919
Hint
| Test point ID | Special constraints | |||
|---|---|---|---|---|
| All are distinct | ||||
| None | ||||
| All are distinct | ||||
| None | ||||
| All are distinct | ||||
| None | ||||
| All are distinct | ||||
| None | ||||
Translated by ChatGPT 5