HomeVolumesContestsSectionsForumsUsersPrintHelpAbout

Contests > IMPC-2014-15 Questions > problem:


Ind_02-10. 50497 - Falling Bricks - Revisited

IMPC-2014-15 Questions

Start: Nov.22.2014 at 03:00:00 PM
Finish: Nov.22.2014 at 08:00:00 PM
The contest is finished!
• Contest scoreboard

Guest
• Review clarifications (1)

Contest problems

• 4th-1. 50491 - Brokers
• 4th-2. 50524 - Elevator
• 4th-3. 50535 - Image Compression
• 4th-6. 50536 - Epoka Furgon Shpk
• Ind_01-10. 50752 - Student Groups
• Ind_01-20. 50416 - Placing Domino...
• Ind_01-30. 50764 - Fast Typing Co...
• Ind_01-50. 50718 - Elevator
• Ind_02-10. 50497 - Falling Bric...
• Ind_02-20. 50745 - Bitonic Sequence
• Ind_02-30. 50657 - Permutations an...
• Ind_03-10. 50743 - Total Scholarshi...
• Ind_03-20. 50515 - Lines - Revisited
• Ind_03-40. 50777 - Dwarfs Maze
• Ind_03-50. 50679 - Jetpack Hurdle J...
• Ind_04-10. 50787 - Expected Value
• Ind_04-20. 50520 - Filling a Matrix ...

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