Cod sursa(job #2702137)

Utilizator beingsebiPopa Sebastian beingsebi Data 2 februarie 2021 22:53:27
Problema Heapuri Scor 100
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.68 kb
#include <bits/stdc++.h>
using namespace std;
ifstream f("heapuri.in");
ofstream g("heapuri.out");
int n, t, v[200009];
priority_queue<int, vector<int>, greater<int>> pq;
unordered_set<int> mst;
int main()
{
    f >> n;
    for (int c, x; n; n--)
    {
        f >> c;
        if (c == 1)
        {
            f >> x;
            v[++t] = x;
            mst.insert(x);
            pq.push(x);
        }
        else if (c == 2)
        {
            f >> x;
            mst.erase(v[x]);
        }
        else
        {
            while (mst.find(pq.top()) == mst.end())
                pq.pop();
            g << pq.top() << '\n';
        }
    }
    return 0;
}