HomeVolumesContestsSectionsForumsUsersPrintHelpAbout

Volumes > C. T. 2011 > problem:


Heap

Volume problems

• A to the power of B
• T-shirts
• GCF
• Maximum Sum
• Making Change
• Best Grass
• Heap
• Bfs
• Chess
• Big Dance
• Binary transformations
• Dijkstra
• Tickets
• Flowers
• Bookshelf

Feedback

If you notice incorrect translations in Contester, please let author know.

Time limit 1000/1000/4000/4000 ms. Memory limit 65000/65000/65000/65000 Kb.

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