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

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

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.

 

 

Expert Solution
steps

Step by step

Solved in 4 steps with 1 images

Blurred answer
Knowledge Booster
Counting Problems
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education