Cod sursa(job #2227093)

Utilizator teodorgTeodor G teodorg Data 31 iulie 2018 11:40:41
Problema Heapuri Scor 100
Compilator cpp Status done
Runda Arhiva educationala Marime 0.82 kb
#include <bits/stdc++.h>
#define fisiere 1
using namespace std;
/**************************************
 *completeaza numele fisiereleor aici *
 **************************************/
const string NUME_PROGRAM="heapuri";
#if fisiere==1
ifstream f(NUME_PROGRAM+".in");
ofstream g(NUME_PROGRAM+".out");
#endif // fisiere
const int N = 200010;
int m,k,x,cod,v[N];
set<int> s;
int main()
{
    f>>m;
    for(;m;m--)
    {
        f>>cod;
        if(cod==3)
        {
            g<<*s.begin()<<'\n';
        }
        else
        {
            f>>x;
            if(cod==1)
            {
                k++;
                v[k]=x;
                s.insert(x);
            }
            else
            {
                x=v[x];
                s.erase(x);
            }
        }
    }
    return 0;
}