Pagini recente » Cod sursa (job #626263) | Cod sursa (job #1240699) | Cod sursa (job #2269231) | Cod sursa (job #1282634) | Cod sursa (job #369152)
Cod sursa(job #369152)
#include<stdio.h>
#include<queue>
#include<bitset>
using namespace std;
typedef pair <int,int> p;
struct cmp
{
bool operator () (const p x,const p y) const
{
return x.first>y.first;
}
};
int n,op,x,which;
bitset <200001> deleted;
priority_queue <p,vector <p>,cmp > heap;
int main()
{
freopen("heapuri.in","r",stdin);
freopen("heapuri.out","w",stdout);
scanf("%d",&n);
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]=true;
}
}
return 0;
}