Cod sursa(job #3033560)
Utilizator | Data | 24 martie 2023 09:18:25 | |
---|---|---|---|
Problema | Heapuri | Scor | 0 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.68 kb |
#include <bits/stdc++.h>
using namespace std;
ifstream fin("heapuri.in");
ofstream fout("heapuri.out");
int n;
bitset<200005> fr;
priority_queue<pair<int, int>> q;
int main()
{
int x, op, poz;
fin >> n;
while (n--)
{
fin >> op;
if (op == 1)
{
fin >> x;
fr[++poz] = 1;
q.push({-x, poz});
}
else if (op == 2)
{
fin >> x;
fr[x] = 0;
}
else
{
while (!q.empty() && fr[q.top().second] == 0)
q.pop();
fout << -q.top().first << "\n";
}
}
return 0;
}
/**
*/