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

5256번 - medians 스페셜 저지다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 128 MB169715747.500%

문제

Let A be a permutation of 1, 2, 3 ..., 2*N - 1.

We define the prefix medians of A as an array B with N elements: where B[i] is the median of A[1], A[2], ..., A[2*i-1].

Note: The median of a list of M numbers (where M is odd) can be found by sorting the numbers and picking the middle one.

You are given N and the array B. You are asked to determine a permutation A whose prefix medians are precisely B.

입력

The input file contains 2 lines. The first line contains one integer, N. The second line describes B: N integers, separated by space.

출력

The output file should contain A: one line with 2*N-1 integers separated by space. If there are multiple permutations A leading to the same input array B, you may output any one. In all test data, there will always be at least one solution.

제한

  • 1 ≤ A[i] ≤ 2*N - 1, for every i from 1 to 2*N - 1
  • 1 ≤ B[i] ≤ 2*N - 1, for every i from 1 to N
  • 1 ≤ N ≤ 100 000

예제 입력 1

5
1 3 3 4 5

예제 출력 1

1 9 3 2 4 8 7 5 6

힌트

출처

Olympiad > Balkan Olympiad in Informatics > BOI 2011 3번

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

출처

대학교 대회

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

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