Pagini recente » Cod sursa (job #879866) | Cod sursa (job #1315) | Cod sursa (job #750134) | Cod sursa (job #650081) | Cod sursa (job #412538)
Cod sursa(job #412538)
#include<stdio.h>
#include<set>
using namespace std;
struct comp {
bool operator()(int i, int j) {
return i<j;
}
};
multiset<int,comp> heap;
int N;
int poz[40002];
int main() {
int t,k=0,x;
freopen("heapuri.in", "r", stdin);
freopen("heapuri.out", "w", stdout);
scanf("%d",&N);
for(int i=1; i<=N;i++) {
scanf("%d",&t);
if(t==1) {
scanf("%d",&x);
heap.insert(x);
poz[++k]=x;
}
if(t==2) {
scanf("%d",&x);
heap.erase(poz[x]);
}
if(t==3) {
x=*heap.upper_bound(0);
printf("%d\n",x);
}
}
return 0;
}