Cod sursa(job #874579)
Utilizator | Robu Gabriel gabriel93 | Data | 8 februarie 2013 21:20:17 |
---|---|---|---|
Problema | Heapuri | Scor | 100 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.69 kb |
#include<stdio.h>
#include<set>
using namespace std;
int n,poz[200002];
multiset<int> h;
void rezolv()
{
int i,tip,x,k;
scanf("%d",&n);
k=0;
for(i=1;i<=n;++i)
{
scanf("%d",&tip);
if(tip==3)
printf("%d\n",*h.begin());
else
{
scanf("%d",&x);
if(tip==1)
{
h.insert(x);
++k;
poz[k]=x;
}
else
h.erase(poz[x]);
}
}
}
int main()
{
freopen("heapuri.in","r",stdin);
freopen("heapuri.out","w",stdout);
rezolv();
fclose(stdin);
fclose(stdout);
return 0;
}