欢迎来到起遇信息学
起遇信息学正处于上线筹建阶段,以下功能已全部开放免费体验: ✅ 完整题库浏览与代码提交评测(C / C++ / Python / Java 等) ✅ 入门到进阶的系列课程试读、作业与考试 ✅ AI 提示、AI 作业分析等智能助教功能 ✅ 赛事模拟与个人能力报告 ✅ 邮箱注册开放 ⏳ 付费课程订阅与微信/支付宝支付通道 ⏳ 手机号登录,微信扫码登录、微信公众号绑定 使用中如遇任何问题,欢迎通过页面底部 **"联系我们"** 与我们沟通。
CF1491A.th Largest Value
th Largest Value
You are given an array consisting of integers. Initially all elements of are either or . You need to process queries of two kinds:
1 x: Assign to the value .2 k: Print the -th largest value of the array.
As a reminder, -th largest value of the array is defined as following:
- Sort the array in the non-increasing order, return -th element from it.
For example, the second largest element in array is , as after sorting in non-increasing order it becomes , and the second element in this array is equal to .
Input
The first line contains two integers and () — the length of the given array and the number of queries.
The second line contains integers () — elements of the initial array.
Each of the following lines contains two integers. The first integer is () — the type of query.
- If the second integer is () — the position of the modified number. You have to assign to the value .
- If the second integer is () — you need to print the -th largest value of the array.
It's guaranteed that there will be at least one query of the second type (satisfying ).
Output
For each query of the second type, print a single integer — the answer to the query.
Note
Initially .
The first operation is printing the third largest value, which is .
The second operation is assigning the value , becomes .
The third operation is printing the third largest value, it is .
The fourth operation is printing the first largest value, it is .
The last operation is printing the fifth largest value, it is .
Samples
5 5
1 1 0 1 0
2 3
1 2
2 3
2 1
2 5
1
0
1
0
在线编程 IDE
建议全屏模式获得最佳体验
| 进入全屏编程 | Alt+E |
| 递交评测 | Ctrl+Enter |
| 注释/取消注释 | Ctrl+/ |
| 缩放字体 | Ctrl+滚轮 |