Pagini recente » Cod sursa (job #2906066) | Cod sursa (job #1617174) | Cod sursa (job #1792391) | Cod sursa (job #3192989) | Cod sursa (job #3041374)
#include<bits/stdc++.h>
using namespace std;
ifstream fin ("heapuri.in");
ofstream fout("heapuri.out");
int n,m;
bool viz[200002];
struct el
{
int nr,poz;
bool operator < (const el &other) const
{
return nr > other.nr;
}
};
priority_queue<el>pq;
int main ()
{
int op,x,y;
fin>>m;
while (m--)
{
fin>>op;
if (op==3)
{
bool ok=0;
while (ok==0)
{
el vf=pq.top();
if (viz[vf.poz]==1)
pq.pop();
else
{
ok=1;
fout<<vf.nr<<'\n';
}
}
}
else
{
fin>>x;
if (op==1)
pq.push({x,++n});
else viz[x]=1;
}
}
}