N I H N: Input
N I H N: Input
Krosh does not remember the exact heights of the cupboards, but for every three consecutive
cupboards he remembers the height difference between the tallest and the shortest of them. In other
words, if the cupboards' heights were h1,h2,…,hnh1,h2,…,hn, then Krosh remembers the
values wi=max(hi,hi+1,hi+2)−min(hi,hi+1,hi+2)wi=max(hi,hi+1,hi+2)−min(hi,hi+1,hi+2) for
all 1≤i≤n−21≤i≤n−2.
Krosh wants to buy such nn cupboards that all the values wiwi remain the same. Help him
determine the required cupboards' heights, or determine that he remembers something incorrectly
and there is no suitable sequence of heights.
Input
The first line contains two integers nn and CC (3≤n≤1063≤n≤106, 0≤C≤10120≤C≤1012) — the
number of cupboards and the limit on possible wiwi.
The second line contains n−2n−2 integers w1,w2,…,wn−2w1,w2,…,wn−2 (0≤wi≤C0≤wi≤C) —
the values defined in the statement.
Output
If there is no suitable sequence of nn cupboards, print "NO".
Otherwise print "YES" in the first line, then in the second line print nn integers h′1,h′2,…,h′nh1′,h2′,
…,hn′ (0≤h′i≤10180≤hi′≤1018) — the heights of the cupboards to buy, from left to right.
We can show that if there is a solution, there is also a solution satisfying the constraints on heights.