Problem E
Fylking hæða
Languages
en
is
As is classical in riddles and puzzles, $n$ individuals have been lined up and they are all of different heights. They are all facing the same way, so the first person sees no one else, the second sees only the first person and so on. Rather than having differently coloured hats or some such they can simply tell how tall everyone in front of them is. You walk down the line and ask each of them how many people in front of them are taller than themselves. Given this information, can you figure out what the internal height order is?
Input
The input starts with a single line containing a single integer $1 \leq n \leq 10^5$, the number of individuals. Next there is a single line with $n$ integers $x_1, x_2, \dots , x_ n$. They satisfy $0 \leq x_ i \leq i - 1$ since the $i$-th person only sees $i - 1$ other people.
Output
Print the numbers $1, 2, \dots , n$ on a single line. Print the numbers in such an order that if the $i$-th number is $j$ then the $i$-th person is the $j$-th shortest. For example if the tallest person comes first, then the shortest, with the last being of a height between the other two, you should print 3 1 2.
Sample Input 1 | Sample Output 1 |
---|---|
7 0 1 0 2 0 2 1 |
3 1 5 2 7 4 6 |