Cod sursa(job #2747220)

Utilizator andi2000Toader Andi andi2000 Data 28 aprilie 2021 22:19:33
Problema Heapuri Scor 100
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.6 kb
#include <iostream>
#include <fstream>
#include <set>

using namespace std;

set <int> heap;
int n, poz[200005], m, cod, x, i;

int main()
{
    ifstream f("heapuri.in");
    ofstream g("heapuri.out");
    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';
    }
    f.close();
    g.close();
    return 0;
}