HomeVolumesContestsSectionsForumsUsersPrintHelpAbout

Volumes > Array and Matrices > problem:


50497 - Falling Bricks - Revisited

Guest
• Review clarifications (1)

Volume problems

• 50442 - Polynomial Addition
• 50869 - Birthday Celebration
• 50870 - ZScore normalization
• 50513 - Climbing Up the Stairs
• 50821 - Derivative of an array
• 50854 - Area of Triangle Revised
• 50520 - Filling a Matrix Randomly
• 51019 - Finding the hidden message
• 50497 - Falling Bricks - Revisited
• 51002 - The most successful classes
• 50847 - The first m trains to leave
• 50669 - Area of an Irregular Polygon
• 50860 - Number of Student Certificates
• 50444 - n digit kth number divisible...
• 50865 - Apartment Building Adminis...
• 50531 - File Decryption
• 50525 - Ordering Pizza

Feedback

If you notice incorrect translations in Contester, please let author know.

Time limit 2000/4000/4000/4000 ms. Memory limit 65000/65000/65000/65000 Kb.
Question by Ibrahim Mesecan.

Falling Bricks - Revisited

Your first program got the interest of the people in the company. Now they ask you some changes in the game. This time, you have again series bricks (integers) with some holes (negative numbers) among them. When a brick falls one down, it fills the empty space. If a brick falls two or more down it also explodes and gets lost. Start processing from the top brick.

Question: Write a program that is going to read bricks information and your program will print the wall after bricks fall down.

Input specification
You will be given an integer (n) the number of bricks where 0 ≤ n ≤ 5000. Then in the following several lines, you will be given n integers where zero and positive numbers represent the bricks. And negative numbers represent the holes. The first brick is the brick at the bottom and the last brick is the one at the top.

Output specification
Show first the number of bombs and then, show the bricks after all bricks fall down.

Sample Input I
6
7 -2 -5
0 -1 3
Sample Output I
3
3 7

Explanation:
There are 3 bombs. The brick 0 disappears, because there are two bombs below that. Then, the remaining bricks are 3 and 7.



Для отправки решений необходимо выполнить вход.

www.contester.ru