Cod sursa(job #2752230)

Utilizator lolotbogdanLolot Stefan-Bogdan lolotbogdan Data 17 mai 2021 09:30:20
Problema Heapuri Scor 100
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.63 kb
#include <iostream>

#include <fstream>

#include <set>



using namespace std;



ifstream f("heapuri.in");

ofstream g("heapuri.out");



set <int> heap;

int N, poz[200010], m, cod, x, i;



int main()

{

    f>>N;

    for(i = 1; i <= N; i++)

    {

        f >> cod;

        if(cod == 1)

        {

            f >> x;

            heap.insert(x);

            poz[++m] = x;

        }

        else if(cod == 2)

        {

            f >> x;

            heap.erase(poz[x]);

        }

        else

            g << *heap.begin() << '\n';

    }

    return 0;

}