Cod sursa(job #2620895)

Utilizator vladdudauDudau Vlad vladdudau Data 29 mai 2020 20:29:46
Problema Heapuri Scor 100
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.63 kb
#include <fstream>
#include <set>
#define N 200001
using namespace std;

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

int ordine[N];
set <int> heap;

int main()
{
    int n, ord = 0;
    in >> n;
    for (int i = 0; i < n; i++)
    {
        int op, x;
        in >> op;
        if(op == 1)
        {
            in >> x;
            heap.insert(x);
            ordine[++ord] = x;
        }
        else if(op == 2)
        {
            in >> x;
            heap.erase(ordine[x]);
        }
        else
        {
            out << *(heap.begin()) << '\n';
        }
    }
    return 0;
}