Pagini recente » Cod sursa (job #2049885) | Cod sursa (job #580772) | Cod sursa (job #790419) | Cod sursa (job #855699) | Cod sursa (job #1920361)
#include <cstdio>
#include <queue>
using namespace std;
struct heap
{
int x,poz;
bool operator <(const heap &aux) const
{
return x>aux.x;
}
};
priority_queue<heap> h;
char vaz[200010];
int main()
{
freopen("heapuri.in", "r", stdin);
freopen("heapuri.out", "w", stdout);
int n,nr=0,tip,x;
scanf("%d",&n);
for(int i=1;i<=n;i++)
{
scanf("%d",&tip);
if(tip==1)
{
scanf("%d",&x);
nr++;
h.push({x,nr});
}
else if(tip==2)
{
scanf("%d",&x);
vaz[x]=1;
}
else
{
while(vaz[h.top().poz]) h.pop();
printf("%d\n",h.top().x);
}
}
return 0;
}