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

Сборники > C. T. 2011 > задача:


Heap

Задачи сборника

• GCF
• Bfs
• Heap
• Chess
• Profits
• Tickets
• Flowers
• Triangle
• Istanbul
• Brackets
• T-shirts

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

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

Лимит времени 1000/1000/4000/4000 мс. Лимит памяти 65000/65000/65000/65000 Кб.

Problem description

Write an implementation of Heap with two operations: Push and Pop.

Input

On the first line of input there is one integer N (1<= N <= 100000). Next N lines are comands. If first number in the line is 0 then you have to Push next value to heap, if it is 1 then Pop maximum value from heap.

Output

For each Pop operation write the extracted value.

Example

stdin stdout

7
0 100
0 10
1
0 5
0 30
0 50
1

100
50

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

www.contester.ru