Cod sursa(job #3033562)

Utilizator PalcPalcu Stefan Palc Data 24 martie 2023 09:22:22
Problema Heapuri Scor 100
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.69 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 = 0;
    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;
}
/**



*/