Лимит времени 2000/4000/4000/4000 мс. Лимит памяти 65000/65000/65000/65000 Кб. 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.
Для отправки решений необходимо выполнить вход.
|