Cod sursa(job #2747487)

Utilizator lazarstefania63@yahoo.comLazar Stefania [email protected] Data 29 aprilie 2021 11:31:57
Problema Heapuri Scor 40
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.65 kb
#include <iostream>
#include <set>
#include <vector>
#include <fstream>

using namespace std;

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

set<int> heap;
vector <int> pos;
int N, i, op, x, idx;

int main()
{
    f >> N;
    pos.assign(200001, 0);

    for (i = 0; i < N; i++)
    {
        f >> op;
        if (op == 1)
        {
            f >> x;
            heap.insert(x);
            pos[++idx] = x;
        }

        else if (op == 2)
        {
            f >> x;
            heap.erase(pos[x]);
        }

        else if (op == 3)
        {
            g << *heap.begin() << endl;
        }

    }
}