doesn't recall the specific statures of the cabinets, however for each three continuous pantries he recollects the tallness contrast between the tallest and the briefest of them. All in all, assuming the pantries' statures were h1,h2,… ,hn, Krosh recalls the qualities wi=max(hi,hi+1,hi+2)−min(hi,hi+1,hi+2) for all 1≤i≤n−2. Krosh needs to purchase such n cabinets that every one of the qualities wi continue as
Correct answer will be upvoted else downvoted. Computer science.
Krosh doesn't recall the specific statures of the cabinets, however for each three continuous pantries he recollects the tallness contrast between the tallest and the briefest of them. All in all, assuming the pantries' statures were h1,h2,… ,hn, Krosh recalls the qualities wi=max(hi,hi+1,hi+2)−min(hi,hi+1,hi+2) for all 1≤i≤n−2.
Krosh needs to purchase such n cabinets that every one of the qualities wi continue as before. Assist him with deciding the necessary pantries' statures, or establish that he remembers something inaccurately and there is no appropriate succession of statures.
Input
The primary line contains two integers n and C (3≤n≤106, 0≤C≤1012) — the number of cabinets and the cutoff on conceivable wi.
The subsequent line contains n−2 integers w1,w2,… ,wn−2 (0≤wi≤C) — the qualities characterized in the assertion.
Output
In case there is no appropriate arrangement of n pantries, print "NO".
In any case print "YES" in the primary line, then, at that point, in the subsequent line print n integers h′1,h′2,… ,h′n (0≤h′i≤1018) — the statures of the cabinets to purchase, from left to right.
We can show that in case there is an answer, there is likewise an answer fulfilling the limitations on statures.
In case there are numerous replies, print any.
Step by step
Solved in 4 steps with 1 images