Time limit per test: 0.25 second(s) Memory limit: 65536 kilobytes
input: standard output: standard
Aof order n is a linear order of 2n objects satisfying the following conditions:
For each i such that 1≤ i≤ n holds
For each i and j such that 1≤ i,j≤ n holds .
(bii is undefined). Let a(i) be the number of such j that . You are given integers a1,a2,..., an. You have to find any bipermutation such that a(i)=ai for all i.
The first line of the input contains single integer n (1≤ n≤ 1000). The next line contains the numbers a1,...,an.
If there is no solution, the only line of the output must contain single word 'NO' (without quotes). Otherwise the first line of the output must contain single word 'YES' (without quotes); the rest of the output must contain the objects ordered with respect to the bipermutation ( is output as -i).
2 0 3 0 4 8 1 5 4
-6 -8 -9 6 -5 -3 8 9 -7 5 -1 -4 3 7 -2 1 4 2
Hint: If and , then .
Novosibirsk SU Contest #2, by Novosibirsk Team #1
Codeforces (c) Copyright 2010-2021 Mike Mirzayanov