Pagini recente » Cod sursa (job #2747924) | Cod sursa (job #2044052) | Cod sursa (job #3175208) | Cod sursa (job #2794001) | Cod sursa (job #2835370)
#include <bits/stdc++.h>
using namespace std;
ifstream fin("heapuri.in");
ofstream fout("heapuri.out");
priority_queue<pair<int,int>, vector<pair<int,int> >, greater<pair<int,int> > > q;
int qq,a,b,tp;
bitset<200005> cancel;
void pr()
{
while(!q.empty()&&cancel[q.top().second])q.pop();
if(!q.empty())fout<<q.top().first<<'\n';
}
void ins(int x)
{
q.push({x,++tp});
}
void rmv(int x)
{
cancel[x]=1;
}
signed main()
{
fin>>qq;
while(qq--)
{
fin>>a;
if(a==3){pr();continue;}
fin>>b;
if(a==1)ins(b);
else rmv(b);
}
return 0;
}