P26150 [AtCoder] [ARC033C] Data Structure
提高-
题目描述

Problem Description

Process the following queries for a set of numbers $ S $.

  • Type $ 1 $: Add the number $ X $ to $ S $.
  • Type $ 2 $: Answer the $ X $-th smallest number in $ S $ and remove that number from $ S $.

Input Format

The input is given from the standard input in the following format:

$ Q $ $ T_1 $ $ X_1 $ $ T_2 $ $ X_2 $ : $ T_Q $ $ X_Q $

  • The first line contains an integer $Q\ (1\ ≦\ Q\ ≦\ 200,000)$, representing the number of queries.
  • The next $ Q $ lines contain the query information. The $ i $-th line contains two integers $T_i\ (1\ ≦\ T_i\ ≦\ 2)$ and $X_i\ (1\ ≦\ X_i\ ≦\ 200,000)$ separated by a space. This represents:
  • If $T_i\ =\ 1$, it means to add the number $ X_i $ to $ S $. It is guaranteed that $ X_i $ is not in $ S $ before processing the query.
  • If $T_i\ =\ 2$, it means to answer the $ X_i $-th smallest number in $ S $ and remove that number from $ S $. It is guaranteed that the number of elements in $ S $ is at least $ X_i $ before processing the query.

Output Format

Let $ Q_2 $ be the number of Type $ 2 $ queries. The output consists of $ Q_2 $ lines. The $ i $-th line should contain the answer for the $ i $-th Type $ 2 $ query. Ensure to include a newline at the end of the output.

Sample Input and Output

Sample Input #1

5
1 11
1 29
1 89
2 2
2 2

Sample Output #1

29
89

Sample Input #2

12
1 8932
1 183450
1 34323
1 81486
1 127874
1 114850
1 55277
1 112706
2 3
1 39456
1 52403
2 4

Sample Output #2

55277
52403

Notes/Hints

None

输入格式

见题面 Input 部分

输出格式

见题面 Output 部分

样例输入
5 1 11 1 29 1 89 2 2 2 2
样例输出
29 89