Pagini recente » Cod sursa (job #3295201) | Cod sursa (job #2569315) | Cod sursa (job #959712) | Cod sursa (job #288142) | Cod sursa (job #420223)
Cod sursa(job #420223)
#include<set>
#include<algorithm>
#include<cstdio>
using namespace std;
struct comp{
bool operator()(long i,long j){
return i<j;
}
};
multiset<long,comp>heap;
//multiset<long>heap;
long N,pos[200005]={0};
//1:insert 2:delete 3:min
int main(){
freopen("heapuri.in","r",stdin);
freopen("heapuri.out","w",stdout);
long t,k=0,x;
scanf("%d",&N);
for(long i=1;i<=N;i++){
scanf("%d",&t);
if(t==1){
scanf("%d",&x);
heap.insert(x);
pos[++k]=x;
}
if(t==2){
scanf("%d",&x);
heap.erase(pos[x]);
}
if(t==3){
printf("%d\n",*heap.upper_bound(0));
}
}
return 0;}