题解 | 【模板】整数优先队列
【模板】整数优先队列
https://www.nowcoder.com/practice/a88e9711f7b04369982bbe8902278ae4?channelPut=tracker3
#include <bits/stdc++.h>
#include <queue>
using ll = long long;
using namespace std;
int main()
{
ll n;
cin>>n;
priority_queue<ll,vector<ll>,greater<ll>>q;
while(n--)
{
int x;
cin>>x;
if(x==1){
int pos;
cin>>pos;
q.push(pos);
}
else if(x==2){
cout<<q.top()<<endl;
}
else {
q.pop();
}
}
return 0;
}
查看24道真题和解析