Cod sursa(job #681142)
| Utilizator | Data | 16 februarie 2012 17:39:45 | |
|---|---|---|---|
| Problema | Heapuri | Scor | 0 |
| Compilator | cpp | Status | done |
| Runda | Arhiva educationala | Marime | 0.7 kb |
#include <stdio.h>
#include<set>
#define Nmax 200001
using namespace std;
int main()
{
int N,i,v[Nmax],c,x;
FILE*f = fopen("heap.in","r");
fscanf(f,"%d",&N);
multiset <int> heap;
v[0] = 0;
FILE*g = fopen("heap.out","w");
while(N--)
{
fscanf(f,"%d",&c);
if(c!=3)
{
fscanf(f,"%d",&x);
if(c==1)
{
heap.insert(x);
v[ ++v[0] ] = x;
}
else
heap.erase( heap.find(v[x]) );
}
else
{
fprintf(g,"%d\n",*(heap.begin()));
}
}
fclose(f);
fclose(g);
return 0;
}
