ГлавнаяСборникиТурнирыРазделыФорумыУчастникиПечатьПомощьО системе

Разделы > Linear Data Structures: Arrays > задача:


50497 - Falling Bricks - Revisited

Гость
• Вопросы к жюри (1)

Задачи раздела

• 50515 - Lines - Revisited
• 50913 - Manhattan Distance
• 50824 - Sum of Group Maxes
• 50449 - The biggest result
• 50442 - Polynomial Addition
• 50982 - A thief in labyrinth
• 50989 - Rectangles and Points
• 50932 - Shifting rows and columns
• 50497 - Falling Bricks - Revisited
• 50933 - Sum of the Biggest Neighbors
• 50444 - n digit kth number divisible...
• 50865 - Apartment Building Adminis...
• 50874 - Apartment Building Adminis...
• 51127 - Maze solver
• 51126 - Dr. Fllanxha
• 51021 - Number of Nodes
• 51044 - Number of Trees

Обратная связь

Если у вас есть предложения или пожелания по работе Contester, посетите форум сайта www.contester.ru.

Лимит времени 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.



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

www.contester.ru