Logo
(追記) (追記ここまで)

18636번 - Restoring a Permutation 스페셜 저지다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
2 초 512 MB42171672.727%

문제

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 length of longest increasing subsequence of p ending at position i is equal to ai,
  • the length of longest decreasing subsequence of p starting at position i is equal to bi.

입력

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.

제한

예제 입력 1

5
1 1 1 2 3
3 2 1 1 1

예제 출력 1

3 2 1 4 5

예제 입력 2

6
1 1 2 2 3 3
2 1 2 1 2 1

예제 출력 2

2 1 4 3 6 5

힌트

출처

Camp > Petrozavodsk Programming Camp > Summer 2019 > Day 6: MIPT Contest G번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /