Cod sursa(job #499929)
Utilizator | Data | 10 noiembrie 2010 23:50:25 | |
---|---|---|---|
Problema | Heapuri | Scor | 40 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.46 kb |
#include <stdio.h>
#include <set>
using namespace std;
int i,n,x,v[200100],m,sw;
multiset<int> heap;
int main()
{
freopen("heapuri.in","r",stdin);
freopen("heapuri.out","w",stdout);
scanf("%d",&n);
m=0;
for(i=0;i<n;i++)
{
scanf("%d",&sw);
if(sw==1||sw==2) scanf("%d",&x);
if(sw==1)
{
m++;
v[m]=x;
heap.insert(x);
}
else
if(sw==2)
heap.erase(v[x]);
else
printf("%d\n",*heap.begin());
}
return 0;
}