Pagini recente » Cod sursa (job #1205104) | Cod sursa (job #1269452) | Cod sursa (job #1646840) | Cod sursa (job #810538) | Cod sursa (job #1643919)
#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);
h.push({x,++nr});
}
else if(tip==2)
{
scanf("%d",&x);
vaz[x]=1;
}
else
{
for(;!h.empty() && vaz[h.top().poz];h.pop());
printf("%d\n",h.top().x);
}
}
return 0;
}