Pagini recente » Cod sursa (job #1523430) | Cod sursa (job #704374) | Cod sursa (job #2698417) | Cod sursa (job #1065561) | Cod sursa (job #1786356)
#include <cstdio>
#include <queue>
using namespace std;
struct heap
{
int valoare, pozitie;
bool operator<(const heap &x) const
{
return valoare > x.valoare;
}
};
priority_queue <heap> v;
char exista[200005];
int N, i, op, x, p = 0;
int main()
{
freopen("heapuri.in", "r", stdin);
freopen("heapuri.out", "w", stdout);
scanf("%d", &N);
for (i=1;i<=N;i++)
{
scanf("%d", &op);
if (op == 1)
{
scanf("%d",&x);
v.push({x,++p});
}
else
if (op == 2)
{
scanf("%d", &x);
exista[x] = 1;
}
else
if (op == 3)
{
while (!v.empty()&&exista[v.top().pozitie])
v.pop();
printf("%d\n",v.top().valoare);
}
}
return 0;
}