All Submissions


You will be given some integers in non-decreasing order, and each time the median is queried you have to report and remove it.

Input Specifications
The input contains many test cases. Read until End Of File.
Each test case contains n (n≤100000) positive integers in non-decreasing order, along with m queries indicated by -1, all on separate lines. (See the example.) For a query, print the current median on a single line and remove it from the list. Each test case ends with 0 on a single line, and two test cases will be separated by an empty line.

All integers are guaranteed to fit in a signed 32-bit container.
A query can only occur if the list is non-empty.

Output Specifications

For each test case output m lines containing the answers to the corresponding queries.
Print an empty line after each test case.

Input

1
2
3
4
-1
-1
5
6
7
-1
0

2
3
-1
0

Output

2
3
5

2



Problem Setter: Jayant Mukherji

Languages: Brain,C,C++,Java,C#,JavaScript,Perl,PHP,Pascal,Python,Ruby,Text

Time Limit: 0.5 Second(s)
Score: 100 Point(s)
Input File Limit: 50000 Bytes

Submit

Login to post clarification.

No Clarifications.

Contest

Mode Judge

Passive

Online

Overall Rankings

RankNameScore
1xyz0
2Ams0
3TIP0
4team420
5xyzz0
6asdasdasd0
7abcd0
8khankhan0
9Gabriel0
10gigel0