Cod sursa(job #2746082)

Utilizator jumpthenfallDan Florin jumpthenfall Data 27 aprilie 2021 14:18:14
Problema Heapuri Scor 40
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.57 kb
#include <set>
#include <fstream>

using namespace std;

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

int N, x, op, idx, i;
set<int> heap;
int v[200001];
int main() 
{

    f >> N;

    for (i = 0; i < N; ++i) 
    {
        f >> op;
        if (op == 1) 
        {
            f >> x;
            heap.insert(x);
            v[++idx] = x;
        }
        else if (op == 2) 
        {
            f >> x;
            heap.erase(v[x]);
        }
        else {
            g << *heap.begin() << endl;
        }
    }
    return 0;

}