Cod sursa(job #353168)
| Utilizator | Data | 4 octombrie 2009 13:00:54 | |
|---|---|---|---|
| Problema | Heapuri | Scor | 100 |
| Compilator | cpp | Status | done |
| Runda | Arhiva educationala | Marime | 0.48 kb |
#include<stdio.h>
#include <queue>
using namespace std;
int n,i,x,y,j;
priority_queue<pair<int, int> > h;
int m=0;
bool del[200003];
int main()
{
freopen("heapuri.in", "r", stdin);
freopen("heapuri.out", "w", stdout);
scanf("%d", &n);
for(i=1;i<=n;i++)
{
scanf("%d", &x);
if(x==3)
{
while(del[h.top().second]==1)
h.pop();
printf("%d\n", -h.top().first);
}
else
{
scanf("%d", &y);
if(x==1)
h.push(make_pair(-y, ++m));
else del[y]=1;
}
}
return 0;
}