Cod sursa(job #2772298)

Utilizator ScobiolaRaduScobiola Radu ScobiolaRadu Data 31 august 2021 17:21:42
Problema Heapuri Scor 100
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.62 kb
#include <iostream>
#include <fstream>
#include<set>

using namespace std;

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

set<int>h;

int main()
{
    int N,v[200001];
    f>>N;
    int comanda,x,i,k=1;
    for(i=1; i<=N; i++)
    {
        f>>comanda;
        if(comanda==1)
        {
            f>>x;
            h.insert(x);
            v[k]=x;
            k++;
        }
        else if(comanda==2)
        {
            f>>x;
            h.erase(v[x]);
        }
        else
        {
            auto it=h.begin();
            g<<*it<<'\n';
        }
    }

    return 0;
}