아직 만들고 있는 페이지입니다.

이 페이지는 아직 만드는 중입니다. 보이는 내용은 바뀔 수 있습니다.

Lost Cows

면접 대비

시간 제한1초메모리 제한1024 MB

요약
각 위치마다 앞에 있는 소 중 더 작은 브랜드의 개수가 주어질 때, 브랜드 1부터 N까지의 원래 순열을 복원한다.
난이도

보통10점 중 6점

유형
배열, 세그먼트 트리, 이분 탐색, 구현
정답자
아직 제출이 없습니다

문제

N (2 ≤ N ≤ 8,000) cows have unique brands in the range 1..N. In a spectacular display of poor judgment, they visited the neighborhood 'watering hole' and drank a few too many beers before dinner. When it was time to line up for their evening meal, they did not line up in the required ascending numerical order of their brands.

Regrettably, FJ does not have a way to sort them. Furthermore, he's not very good at observing problems. Instead of writing down each cow's brand, he determined a rather silly statistic: For each cow in line, he knows the number of cows that precede that cow in line that do, in fact, have smaller brands than that cow.

Given this data, tell FJ the exact ordering of the cows.

입력

  • Line 1: A single integer, N
  • Lines 2..N: These N-1 lines describe the number of cows that precede a given cow in line and have brands smaller than that cow. Of course, no cows precede the first cow in line, so she is not listed. Line 2 of the input describes the number of preceding cows whose brands are smaller than the cow in slot #2; line 3 describes the number of preceding cows whose brands are smaller than the cow in slot #3; and so on.

출력

  • Lines 1..N: Each of the N lines of output tells the brand of a cow in line. Line #1 of the output tells the brand of the first cow in line; line 2 tells the brand of the second cow; and so on.

예제1

  1. 예제 1

    입력
    5
    1
    2
    1
    0
    
    예상 출력
    2
    4
    5
    3
    1