Cod sursa(job #499923)
| Utilizator | Data | 10 noiembrie 2010 23:42:40 | |
|---|---|---|---|
| Problema | Heapuri | Scor | 40 |
| Compilator | cpp | Status | done |
| Runda | Arhiva educationala | Marime | 0.5 kb |
#include <stdio.h>
#include <set>
using namespace std;
set<int> heap;
set<int>::iterator it;
int i,n,x,v[200100],m,sw;
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
{
it=heap.begin();
printf("%d\n",*it);
}
}
return 0;
}
