Frogs
시간 제한1초메모리 제한256 MB
인접한 바위 사이 구간별로 관측된 이동 횟수가 주어질 때, 각 바위에 정확히 한 마리씩 남도록 n마리 개구리가 동시에 점프한 결과가 그 횟수와 일치하는 순열을 복원하거나 불가능을 판정한다.
문제
There are frogs sitting on 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 to 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 -th frog as . Some frogs may have possibly jumped in place, that is, may be equal to .
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 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 that satisfies the observed numbers of crossings.
입력
The first line contains an integer , the number of frogs ().
The second line contains space-separated integers (), -th of them denotes the number of frogs that crossed the interval between rocks and .
출력
If a required permutation doesn't exist, output "No" (without the quotes). Otherwise, output "Yes" on the first line. On the second line, output integers 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.