#P2343. 宝石管理系统

宝石管理系统

Description

GY bought a batch of gemstones and put them in a warehouse. One day, GY decided to count them, so he took out mm gemstones and put them into a gemstone management system. Each gemstone ii has a value viv_i. He hopes you can write a program to find the nn-th most valuable gemstone in descending order. However, there is a problem: he carelessly left some gemstones in the warehouse, and he may add them to the current system. The number of such gemstones is small. He is sorry, but he still hopes your system will work.

Input Format

The first line contains two integers m,qm, q, the number of gemstones already taken out and the number of following queries or insertions.

The second line contains mm integers, the values of these mm gemstones.

Each of the following qq lines contains two integers c,nc, n.

If c=1c = 1 (query), output the current nn-th most valuable gemstone.

If c=2c = 2 (insertion), insert a gemstone with value nn into the system.

Output Format

For each case with c=1c = 1 (query), output the value viv_i of the current nn-th most valuable gemstone.

5 3
1 3 2 5 6
1 3
2 4
1 6

3
1

Hint

  • For 50%50\% of the testdata, there is no case with c=2c = 2.
  • For 100%100\% of the testdata, m100000m \leq 100000, the number of cases with c=2c = 2 does not exceed 1000010000, q30000q \leq 30000, 0vi<2310 \leq v_i < 2^{31}.

Translated by ChatGPT 5