[BOJ 15403] Escape Room
View as PDFAs you know, escape rooms became very popular since they allow you to play the role of a video game hero. One such room has the following quiz. You know that the locker password is a permutation of N numbers. A permutation of length N is a sequence of distinct positive integers, whose values are at most N. You got the following hint regarding the password - the length of the longest increasing subsequence starting at position i equals Ai. Therefore you want to find the password using these values. As there can be several possible permutations you want to find the lexicographically smallest one. Permutation P is lexicographically smaller than permutation Q if there is an index i such that Pi < Qi and Pj = Qj for all j < i. It is guaranteed that there is at least one possible permutation satisfying the above constraints. Can you open the door?
입력 형식
The first line of the input contains one integer N (1 ≤ N ≤ 105).</p>
The next line contains N space-separated integer Ai (1 ≤ Ai ≤ N).
It’s guaranteed that at least one possible permutation exists.
출력 형식
Print in one line the lexicographically smallest permutation that satisfies all the conditions.
예제 입력 1
4
1 2 2 1
예제 출력 1
4 2 1 3
예제 입력 2
1
1
예제 출력 2
1
Comments