Pagini recente » Cod sursa (job #3283170) | Cod sursa (job #2723951) | Cod sursa (job #1161171) | Cod sursa (job #2692171) | Cod sursa (job #485470)
Cod sursa(job #485470)
#include <cstdio>
#include <queue>
#include <algorithm>
using namespace std;
#define x first
#define y second
#define mp make_pair
const int MAX_N = 200001;
int f[MAX_N];
priority_queue <pair<int, int> > h;
int main()
{
freopen("heapuri.in", "r", stdin);
freopen("heapuri.out", "w", stdout);
int cnt = 0, t, nr;
for (scanf("%d", &t); t; --t)
{
int q;
scanf("%d", &q);
if (q == 3)
{
for (; f[h.top().y]; h.pop());
printf("%d\n", h.top().x * (-1));
continue;
}
scanf("%d", &nr);
if (q == 1)
{
++cnt;
h.push(mp(nr * (-1), cnt));
}
else
f[nr] = 1;
}
}