시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
---|---|---|---|---|---|
2 초 | 512 MB | 14 | 9 | 9 | 81.818% |
You are given a positive integer n and two arrays a and b containing n integers each.
You need to find permutation p of length n such that for each i ∈ {1, 2, . . . , n} the following two conditions are satisfied:
The first line of input contains a positive integer n (1 ≤ n ≤ 2 · 105), the length of the permutation.
The second line contains n integers a1, a2 . . . , an, where ai (1 ≤ ai ≤ n): the length of longest increasing subsequence ending at position i.
The third line contains n integers b1, b2 . . . , bn, where bi (1 ≤ bi ≤ n): the length of longest decreasing subsequence starting at position i.
Print a line containing n space-separated integers p1, p2, . . . , pn: the desired permutation.
It is guaranteed that the answer exists. If there are multiple solutions, you may print any one of them.
5 1 1 1 2 3 3 2 1 1 1
3 2 1 4 5
6 1 1 2 2 3 3 2 1 2 1 2 1
2 1 4 3 6 5