Cod sursa(job #2745571)

Utilizator almar.fetaFeta Almar almar.feta Data 26 aprilie 2021 19:10:40
Problema Heapuri Scor 100
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.61 kb
#include <fstream>
#include <set>

using namespace std;

ifstream in("heapuri.in");
ofstream out("heapuri.out");

int n,cod,x,len;

set <int> heap;
int nr[200001];

int main()
{
    in >> n;
    for(int i=1; i<=n; i++)
    {
        in >> cod;
        if(cod == 1)
        {
            in >> x;
            nr[++len] = x;
            heap.insert(x);
        }
        else if(cod == 2)
        {
            in >> x;
            heap.erase(nr[x]);
        }
        else if(cod == 3)
            out << *heap.begin() << "\n";
    }

    in.close();
    out.close();
    return 0;
}