题解
2026-10-11 17:53:43
发布于:黑龙江
0阅读
0回复
0点赞
#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll q,ops,x,k,idx=0;
multiset<ll> s;
int main(){
cin>>q;
while(q--){
cin>>ops;
if(ops==1){
cin>>x;
s.insert(x);
}else if(ops==2){
cin>>x>>k;
auto m=s.upper_bound(x);
bool ok=1;
for(int i=0;i<k;i++){
if(m==s.begin()){
ok=0;
break;
}
--m;
}
if(ok)cout<<*m<<endl;
else cout<<-1<<endl;
}else{
cin>>x>>k;
auto m=s.lower_bound(x);
bool ok=1;
for(int i=1;i<k;i++){
if(m==s.end()){
ok=0;
break;
}
++m;
}
if(m==s.end()){
ok=0;
}
if(ok)cout<<*m<<endl;
else cout<<-1<<endl;
}
}
return 0;
}
这里空空如也







有帮助,赞一个