Pagini recente » Cod sursa (job #2016199) | Cod sursa (job #838081) | Cod sursa (job #608439) | Cod sursa (job #205775) | Cod sursa (job #2101640)
#include<bits/stdc++.h>
using namespace std;
ifstream in("heapuri.in");
ofstream out("heapuri.out");
struct elem { int val,poz;
bool operator < (const elem &a)const{return val>a.val;}
};
int n,p;
bool sters[200002];
int main(){
priority_queue <elem> Q;
in>>n;
int i,k,x;
k=0;
elem w;
for(i=1;i<=n;++i){
in>>p;
if(p==1){
in>>x;
w.val=x;
w.poz=++k;
Q.push(w);
}
if (p==2){
in>>x;
sters[x]=true;
}
if(p==3){
w=Q.top();
while(sters[w.poz]==true){
Q.pop();
w=Q.top();
}
out<<w.val<<"\n";}
}
return 0;}