Cod sursa(job #2571106)

Utilizator FrostfireMagirescu Tudor Frostfire Data 4 martie 2020 21:05:58
Problema Heapuri Scor 100
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.66 kb
#include <iostream>
#include <fstream>
#include <set>
#define NMAX 200000

using namespace std;

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

int q, a[NMAX+10], k;
set <int> s;

int main()
{
    f >> q;
    while(q--)
        {   int type;
            f >> type;
            if(type == 1)
                {   int x;
                    f >> x;
                    a[++k] = x;
                    s.insert(x);
                }
            else if(type == 2)
                {   int x;
                    f >> x;
                    s.erase(a[x]);
                }
            else g << *s.begin() << '\n';
        }
    return 0;
}