К-th maximum
Write a program that implements a data structure that allows to add and remove items, and also to find the k-th maximum.
Input
The first line contains the number of commands n (n ≤ 10^5
). Each of the next n lines contains one command. The command is given in the form of two numbers c[i]
and k[i]
- the type and the argument of the command respectively (|k[i]
| ≤ 10^9
). Supported commands are:
+1: Add element with key
k[i]
;0: Find and print the
k[i]
-th maximum;-1: Delete the element with a key
k[i]
.
It is guaranteed that during simulation it is not required to store in structure the items with equal keys, or to remove non-existent elements. It is also guaranteed that at the request of k[i]
-th maximum, it exists.
Output
For each command of zero type print a string with a single number - the k[i]
-th maximum.