Cod sursa(job #2746644)

Utilizator LsbogdanBogdan Lsbogdan Data 28 aprilie 2021 11:06:45
Problema Heapuri Scor 100
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.57 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;
}