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

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

Frogs

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

요약
인접한 바위 사이 구간별로 관측된 이동 횟수가 주어질 때, 각 바위에 정확히 한 마리씩 남도록 n마리 개구리가 동시에 점프한 결과가 그 횟수와 일치하는 순열을 복원하거나 불가능을 판정한다.
난이도

보통10점 중 7점

유형
그리디, 배열, 수학, 구현
정답자
아직 제출이 없습니다

문제

There are nn frogs sitting on nn rocks which are located on a straight line. Each rock contains exactly one frog. The rocks (as well as the frogs) are numbered by consecutive integers from 11 to nn in the order of their positions on the line. 

The frogs have a secret plan of taking over the world that involves all of them performing jumps at the same time in such way that, after their jumps, each rock still contains exactly one frog. Denote the destination rock of the ii-th frog as p_ip\_i. Some frogs may have possibly jumped in place, that is, p_ip\_i may be equal to ii.

There is a satellite high in the sky that tracks the frogs' movements. For technical reasons, it only tracks targets that are in motion. So the information it provides is the following: for each of the n−1n-1 intervals between the rocks, it is known how many frogs crossed this interval in either direction.

The frogs have jumped once as described above. Find any sequence p_ip\_i that satisfies the observed n−1n - 1 numbers of crossings.

입력

The first line contains an integer nn, the number of frogs (2≤n≤200,0002 \leq n \leq 200\\,000).

The second line contains n−1n - 1 space-separated integers a_1,…,a_n−1a\_1, \ldots, a\_{n-1} (0≤a_i≤200,0000 \leq a\_i \leq 200\\,000), ii-th of them denotes the number of frogs that crossed the interval between rocks ii and i+1i + 1.

출력

If a required permutation doesn't exist, output "No" (without the quotes). Otherwise, output "Yes" on the first line. On the second line, output nn integers p_1,p_2,…,p_np\_1, p\_2, \ldots, p\_n such that if the frogs perform jumps according to this sequence, each rock still contains exactly one frog, and the observed numbers of crossings of all intervals between the rocks are as given. If there are several possible answers, output any one of them.

예제2

  1. 예제 1

    입력
    5
    2 4 2 2
    
    예상 출력
    Yes
    4 3 2 5 1
    
  2. 예제 2

    입력
    4
    1 2 3
    
    예상 출력
    No