Cod sursa(job #2896059)

Utilizator Stefan_MagureanuMagureanu Stefan Stefan_Magureanu Data 29 aprilie 2022 19:34:05
Problema Heapuri Scor 100
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.65 kb
#include <fstream>
#include <set>

using namespace std;
ifstream fin("heapuri.in");
ofstream fout("heapuri.out");

int main() {
    int elemente_introduse[200001], count = 0;
    set<int> heap;
    int n, op, x;
    fin >> n;
    for (int i = 0; i < n; i++) {
        fin >> op;
        if (op == 1) {
            fin >> x;
            heap.insert(x);
            elemente_introduse[++count] = x;
        } else if (op == 2) {
            fin >> x;
            heap.erase(elemente_introduse[x]);
        } else if (op == 3) {
            auto it = heap.begin();
            fout << *it << "\n";
        }
    }
    fin.close();
    fout.close();
    return 0;
}