subject

Rob anderson is creating a spooky decoration for halloween. rob has a bracket in the ceiling, and he will hook on chain links to make a drooping chain to give his room a dungeony feel. rob has a large collection of chain links to make the decoration. each link has a particular grade, which represents the amount of weight (in chain links, all of which have equal weight) that can be hung from it without breaking. a grade of weight 0 means that any link hung underneath will snap the link. rob’s roommate anne does understand the concepts of link grades, and was told by rob to hang up the links. anne will take each link (in order of rob’s collection) and hang it on the lowest hanging chain or on the bracket, if no chains are currently hanging from the ceiling. if a chain section falls to the ground anne will simply ignore it. this means that there is a very high chance that rob will come home to a large number of chain links (broken and not) lying on the floor. take in the grades of rob’s chain link collection, and determine how many links will break, which ones break, and how many chains should be hanging from the ceiling.

input specification: the input will contain multiple lines. the i-th line of input will contain a non-negative integer gi, representing the grade of the i-th link in the chain link collection. input will be terminated with a negative grade.

output specification: every time a link breaks, a line containing the phrase chain broken at link x. new height is y. should be printed, where x is the value representing the chain link in input that broke a link, and y is the number of chains currently hanging from the ceiling. the last 2 lines of output should be the following, ending chain height is x. there are y broken links and z whole links on the floor. the value x should be how many links are hanging from the ceiling, the value y will be how many links broke during annes link hanging, and z will be the number of links that never broke, but fell due to high links breaking.

ansver
Answers: 1

Other questions on the subject: Computers and Technology

image
Computers and Technology, 24.06.2019 00:30, rustjallison9928
Asecurity policy is a a. set of guidlines b. set of transmission protocols c. written document d. set of rules based on standards and guidelines
Answers: 2
image
Computers and Technology, 24.06.2019 03:30, ava1018
The footer area of a web page generally houses which website feature? terms of use web page content business name or title menu headings
Answers: 1
image
Computers and Technology, 24.06.2019 07:00, janeliles
Why would a business likely use a java applet - to back up their data files for the business - to create a program that a customer can launch in their web browser - to create music on a powerpoint presentation - to organize files on their company directory
Answers: 3
image
Computers and Technology, 24.06.2019 09:00, king514
Technician a says that a new replacement part is always good. technician b says that sometimes recent repair work will be the cause of a complaint. who is correct? a. both technicians a and b b. technician a c. technician b d. neither technician a nor b
Answers: 3
You know the right answer?
Rob anderson is creating a spooky decoration for halloween. rob has a bracket in the ceiling, and he...

Questions in other subjects: