Cod sursa(job #2747837)

Utilizator IoanaLiviaPopescuIoana Livia IoanaLiviaPopescu Data 29 aprilie 2021 18:06:41
Problema Heapuri Scor 100
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.59 kb
#include <iostream>
#include <fstream>
#include <set>

using namespace std;


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

set <int> heap;
int N, v[200001], x, tip, k;

int main() {

    f>>N;

    for (int i = 1; i <= N; i++) {
        f >> tip;
        if (tip == 1) {
            f >> x;
            heap.insert(x);
            v[++k] = x;
        }
        else {
            if (tip == 2) {
                f >> x;
                heap.erase(v[x]);
            } else {
                g << *heap.begin() << '\n';
            }
        }
    }

    g.close();
    f.close();

    return 0;
}