Cod sursa(job #2896103)

Utilizator robert2211Barbu Robert-Gabriel robert2211 Data 29 aprilie 2022 19:58:56
Problema Heapuri Scor 100
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.58 kb
#include <bits/stdc++.h>

using namespace std;

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

set<int> h;

int main()
{

    int N, operatie, x, i, pozitie=1, pozitii[200001];
    f>>N;
    for(i=0; i<N; i++)
    {
        f>>operatie;
        if(operatie==1)
        {
            f>>x;
            h.insert(x);
            pozitii[pozitie]=x;
            pozitie++;
        }
        if(operatie==2)
        {
            f>>x;
            h.erase(pozitii[x]);
        }
        if(operatie==3)
            g<<*h.begin()<<'\n';
    }


    return 0;
}