Order Statistics Live
Maintain a multiset under three operations: I x insert x, D x delete one copy of x (if present), and K k print the k-th smallest element (or −1 if fewer than k exist).
Input: the first line has Q; each of the next Q lines is an operation.
Output: one line per K query.
Constraints:
- 1 ≤ Q ≤ 105
- |x| ≤ 109
Sample Tests
Input 1
5 I 5 I 2 I 8 K 2 K 3
Output 1
5 8
Input 2
2 I 1 K 1
Output 2
1
Discussion (opens after you solve — no spoilers before)
No comments yet.