Pagini recente » Cod sursa (job #2733667) | Cod sursa (job #1192524) | Cod sursa (job #969348) | Cod sursa (job #2943051) | Cod sursa (job #369151)
Cod sursa(job #369151)
#include<stdio.h>
#include<queue>
#include<vector>
using namespace std;
typedef pair <int,int> p;
struct cmp
{
bool operator () (p x,p y) const
{
return x.first>y.first;
}
};
int n,op,x,which;
priority_queue <p,vector <p>,cmp > heap;
int main()
{
freopen("heapuri.in","r",stdin);
freopen("heapuri.out","w",stdout);
scanf("%d",&n);
vector <bool> deleted(n+1,0);
for(int i=0;i<n;i++)
{
scanf("%d",&op);
if(op==3)
{
for(;deleted[heap.top().second];heap.pop());
printf("%d\n",heap.top().first);
continue;
}
scanf("%d",&x);
if(op==1)
{
heap.push(p(x,++which));
}
else
{
deleted[x]=1;
}
}
return 0;
}