Pagini recente » Cod sursa (job #2123072) | Cod sursa (job #352934) | Cod sursa (job #2837480) | Cod sursa (job #674223)
Cod sursa(job #674223)
#include<stdio.h>
#include<queue>
#define Nmax 2000009
using namespace std;
struct cmp
{
bool operator()(const pair<int,int> &x,const pair<int,int> &y)
{
if (x.first==y.first) return x.second>y.second;
return x.first>y.first;
}
};
priority_queue<pair<int,int>,vector< pair<int,int> >,cmp> Q;
int x,N,n,i,t,ok[Nmax];
int main()
{
freopen("heapuri.in","r",stdin);
freopen("heapuri.out","w",stdout);
scanf("%d",&n);
for (i=1;i<=n;i++)
{
scanf("%d",&t);
if (t==1)
{
scanf("%d",&x);
Q.push(make_pair(x,++N));
}
else if (t==2)
{
scanf("%d",&x);
ok[x]=1;
}
else
{
while (ok[Q.top().second]) Q.pop();
printf("%d\n",Q.top().first);
}
}
}