Pagini recente » Istoria paginii runda/springfest | Istoria paginii utilizator/3milac8622rg3 | Istoria paginii runda/superboolaneala | Profil CristianSirbu | Cod sursa (job #353168)
Cod sursa(job #353168)
#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;
}