The Wall - Acil Yardim

Problem 2 – The Wall
- "The White Walkers sleep beneath the ice for thousands of years. And when they wake up..." 
- "And when they wake up... what?"
- "I hope the Wall is high enough."
The Wall is a colossal fortification which is being built to stretch for 100 leagues (300 miles) along the northern border of the Seven Kingdoms. Its purpose is to defend the realm from the wildlings who live beyond. The Wall is reported to be 30 foot tall and is made of solid ice. The Sworn Brothers of the Night's Watch have arranged that each section has its own construction crew.

Write a program that keeps track of material quantities and cost for the construction of the 30-foot wall. You will be given a series of numbers on a single line, separated by space. These numbers represent the initial heights of different mile-long sections of the wall, in feet. Each of these sections has its own construction crew that can add 1 foot of height per day. All crews work simultaneously (see examples), meaning all sections that aren’t completed (are less than 30 feet high) grow by 1 foot every day. When a section of the wall is completed, its crew is relieved.
Each foot added uses 195 cubic yards of ice. To process one cubic yard, it costs the Night’s Watch 1900 "Gold Dragon" coins for salaries and food for the brothers who work on it.
Your program needs to keep track of how much ice is used daily until the completion of the entire wall. At the end, print on a single line, separated by comma and space, the amount of ice used each day, and on a second line, the final cost for the constructions on the wall.
Input
The input consists of 1 line, containing numbers, separated by space.
Output
The output consists of 2 lines:
First line: Print the amount of ice used each day, separated by comma and space.
Second line: Show the final cost of the wall.
Constraints
The wall may contain up to 2000 sections (2000 elements in the initial array)
Starting height for each section is within range [0…30]

Scroll down to see detailed examples. 

Examples
Input    Output
21 25 28    585, 585, 390, 390, 390, 195, 195, 195, 195
5928000 coins

Explanation:
On the first day, all three crews work simultaneously, each adding 1 foot to their section: 3 x 195 = 585 cubic yards in total. 
On the second day, it’s the same. However, the last section reaches 30 feet and its crew is being relieved (the crews that don’t work are marked in green).
On the third day, only two crews work, using up 390 cubic yards in total. 
This continues for 2 more days, with the second section reaching 30 feet.
In the remaining 4 days, only 1 crew works, using 195 cubic yards every day. Over the entire period, 3120 cubic yards of ice were used. This whole construction costed the Night’s Watch 5 928 000 coins worth salaries and food for the brothers who built it. And that’s it!    Starting
Day 1
Day 2
Day 3
Day 4
Day 5
Day 6
Day 7
Day 8
Day 9    [21, 25, 28]
[22, 26, 29]
[23, 27, 30]
[24, 28, 30]
[25, 25, 30]
[26, 30, 30]
[27, 30, 30]
[28, 30, 30]
[29, 30, 30]
[30, 30, 30]
See more examples: 
Input    Output
17    195, 195, 195, 195, 195, 195, 195, 195, 195, 195, 195, 195, 195
4816500 coins
Explanation
Here only one section with initial height of 17 foot is being built. The crew works for 13 days, adding 1 foot each day, until the desired height of 30 feet is reached. The final cost for salaries and food for this construction is 4 816 500 "Gold Dragon" coins.

Input    Output
17 22 17 19 17    975, 975, 975, 975, 975, 975, 975, 975, 780, 780, 780, 585, 585
21489000 coins

  • Etiketler;
Cevap Yaz

Cevap yazabilmek için üye girişi yapmanız gerekiyor!

Yukarı Git