Cod sursa(job #2737165)

Utilizator blxqnAlina Voiculescu blxqn Data 4 aprilie 2021 14:48:02
Problema Heapuri Scor 0
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.76 kb
#include <iostream>
#include <fstream>
#include <set>

using namespace std;

ifstream fin("hashuri.in");
ofstream fout("hashuri.out");

set <int> heap;

int pos[200005];
int n, operation, idx, x;

int main()
{
    fin>>n;
    for (int i = 1; i <= n; i++)
    {
        fin>>operation;
        //while (!heap.empty())
        //{
        //    cout<<*heap.begin()<<endl;
        //    heap.erase(*heap.begin());
        //}
        if (operation == 1)
        {
            fin>>x;
            heap.insert(x);
            idx += 1;
            pos[idx] = x;
        }
        else if (operation == 2)
        {
            fin>>x;
            heap.erase(pos[x]);
        }
        else fout<<*heap.begin()<<endl;
    }
    return 0;
}