#K8586. Seesaw Balance Challenge

    ID: 36735 Type: Default 1000ms 256MiB

Seesaw Balance Challenge

Seesaw Balance Challenge

Given a set of unique integer weights, determine if it is possible to arrange them on a seesaw so that it is perfectly balanced. Each weight must be placed at a unique position chosen from the set ({-n, -n+1, \ldots, -1, 1, 2, \ldots, n}), where (n) is the number of weights. The seesaw is balanced if the net moment about the fulcrum is zero, that is, (\sum_{i=1}^{n} w_i \times p_i = 0), where (w_i) is the (i^{th}) weight and (p_i) is its corresponding position. If such an arrangement exists, output one valid configuration; otherwise, output "NO".

inputFormat

The input is given via standard input. The first line contains an integer (n) representing the number of weights. The second line contains (n) space-separated integers representing the weights.

outputFormat

If a valid arrangement exists, print "YES" on the first line and on the second line print (n) space-separated integers representing the positions (from the set ({-n, \ldots, -1, 1, \ldots, n})) corresponding to the input weights in their given order. If no valid arrangement exists, print just "NO".## sample

3
1 2 3
YES

-3 3 -1

</p>