시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
---|---|---|---|---|---|
1 초 | 256 MB | 57 | 39 | 37 | 80.435% |
Given $f_1, f_2, \ldots, f_n$, find a permutation $p_1, p_2, \ldots, p_n$ of integers $1, 2, \ldots, n$ such that, for each $i$, the length of the longest strictly increasing subsequence ending with $p_i$ is $f_i$.
The first line contains an integer $n$ ($1 \leq n \leq 10^5$).
The second line contains $n$ integers $f_1, f_2, \ldots, f_n$ ($1 \leq f_i \leq n$). It is guaranteed that, for the given input, at least one such permutation $p_1, p_2, \ldots, p_n$ exists.
On the first line, print $n$ integers $p_1, p_2, \ldots, p_n$. These numbers must form a permutation of integers $1, 2, \ldots, n$. If there are several possible answers, print any one of them.
7 1 1 1 1 1 1 1
7 6 5 4 3 2 1
7 1 2 3 2 4 4 3
1 3 5 2 7 6 4