Longest Increasing Subsequence
Time limit1sMemory limit256 MB
Given target LIS-ending lengths f_i, construct a permutation of 1..n whose longest increasing subsequence ending at position i has length exactly f_i.
- Level
Medium7 of 10
- Topics
- Greedy, Sorting, Array, Implementation
- Solved
- No attempts yet
Problem
Given , find a permutation of the integers such that for each , the length of the longest strictly increasing subsequence ending with is .
Input
The first line contains an integer ().
The second line contains integers (). It is guaranteed that for the given input, at least one permutation satisfying the condition exists.
Output
On the first line, print integers . These numbers must form a permutation of . If there are several possible answers, print any one of them.