Cod sursa(job #2537765)

Utilizator cyg_Alex_codegicianBarbu Alexandru cyg_Alex_codegician Data 3 februarie 2020 22:22:54
Problema Heapuri Scor 100
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.56 kb
#include <fstream>
#include <set>
using namespace std;
ifstream fin ("heapuri.in");
ofstream fout ("heapuri.out");
int main()
{
    const int nmax=200005;
    int n,poz=0,a[nmax];
    fin >> n;
    set <int> heap;
    for (int i=1;i<=n;i++)
    {
        int op,x;
        fin >> op;
        if (op==1)
        {
            fin >> x;
            heap.insert(x);
            poz++;
            a[poz]=x;
        }
        else if (op==2)
        {
            fin >> x;
            heap.erase(a[x]);
        }
        else if (op==3) fout << *heap.begin() << '\n';
    }
}