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

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


50497 - Falling Bricks - Revisited

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

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

• 51091 - Guess the number - 1
• 51008 - Sum of Regional Maxes
• 50989 - Rectangles and Points
• 51020 - Number of nodes removed
• 50932 - Shifting rows and columns
• 51141 - Most valuable stock items
• 51014 - Nine Men's Morris game
• 51019 - Finding the hidden message
• 50497 - Falling Bricks - Revisited
• 50933 - Sum of the Biggest Neighbors
• 51100 - Minimum time to exit building
• 50444 - n digit kth number divisible...
• 50865 - Apartment Building Adminis...
• 51089 - Multiply a row and add it to ...
• 50874 - Apartment Building Adminis...
• 50531 - File Decryption
• 51012 - Palindrome-k

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

Если у вас есть предложения или пожелания по работе 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