2663. Special Container

单点时限: 2.0 sec

内存限制: 256 MB

Design a container, which has two kinds of operation, push and pop.

Push: You should push the given number into the container.

Pop: Please find the middle number of the container. If these is n numbers in container, it will be the (n+1)/2-th num when sort increased. Then pop the number.

输入格式

The input contains one or more data sets. At first line of each input data set is an integer N (1<= N <= 100000) indicate the number of operations.

Then N lines follows, each line contains a number (0 or 1). “0” means a push operation, it’s followed by an integer E. “1” means a pop operation.

You may assume all the numbers in the input file will be in the range of 32-bit integer.

输出格式

For each pop operation, you should print the integer popped. Please print “No Element!”, if there is no number to pop. Please print a blank line after each data set.

样例

Input
9
0 10
0 -10
0 5
1
1
0 2
1
1
1
3
0 2
0 1
1
Output
5
-10
2
10
No Element!
1

8 人解决,15 人已尝试。

31 份提交通过,共有 63 份提交。

6.6 EMB 奖励。

创建: 15 年,4 月前.

修改: 7 年,3 月前.

最后提交: 1 年,5 月前.

来源: N/A

题目标签