#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 gemstones and put them into a gemstone management system. Each gemstone has a value . He hopes you can write a program to find the -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 , the number of gemstones already taken out and the number of following queries or insertions.
The second line contains integers, the values of these gemstones.
Each of the following lines contains two integers .
If (query), output the current -th most valuable gemstone.
If (insertion), insert a gemstone with value into the system.
Output Format
For each case with (query), output the value of the current -th most valuable gemstone.
5 3
1 3 2 5 6
1 3
2 4
1 6
3
1
Hint
- For of the testdata, there is no case with .
- For of the testdata, , the number of cases with does not exceed , , .
Translated by ChatGPT 5
京公网安备 11011102002149号