Cod sursa(job #2327278)

Utilizator usureluflorianUsurelu Florian-Robert usureluflorian Data 24 ianuarie 2019 16:13:17
Problema Heapuri Scor 100
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.53 kb
#include <bits/stdc++.h>
using namespace std;
ifstream f ("heapuri.in");
ofstream g ("heapuri.out");
set <int> h;
const int nmax=2e5+3;
int nr,n,caz,x,v[nmax];
int main()
{
    ios::sync_with_stdio(false);
    f>>n;
    for(int i=1;i<=n;++i)
    {
        f>>caz;
        if(caz==1)
        {
            f>>x;
            v[++nr]=x;
            h.insert(x);
        }
        else if(caz==2)
        {
            f>>x;
            h.erase(v[x]);
        }
        else g<<*h.begin()<<'\n';
    }
    return 0;
}