Pagini recente » Cod sursa (job #2750724) | Cod sursa (job #1204114) | Cod sursa (job #450118) | Cod sursa (job #2263406) | Cod sursa (job #2624705)
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> p;
priority_queue <p,vector<p>,greater<p>> h;
vector <int> v(200005);
vector <bool> sel(200005);
int n;
int main()
{
freopen("heapuri.in","r",stdin);
freopen("heapuri.out","w",stdout);
cin.sync_with_stdio(false);
cin.tie(0);
cin>>n;
int cnt=0;
for(int i=1; i<=n; ++i)
{
int t;
cin>>t;
if(t==1)
{
int x;
cin>>x;
++cnt;
v[cnt]=x;
h.push({x,cnt});
}
else if(t==2)
{
int x;
cin>>x;
sel[x]=true;
}
else if(t==3)
{
while(sel[h.top().second])
{
h.pop();
}
cout<<h.top().first<<'\n';
}
}
}