Cod sursa(job #2745696)

Utilizator RobertLitaLita Robert RobertLita Data 26 aprilie 2021 21:56:06
Problema Heapuri Scor 100
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.6 kb
#include <iostream>
#include <fstream>
#include <set>
using namespace std;
ifstream f("heapuri.in");
ofstream g("heapuri.out");
set<int> heap;
int main()
{
    int poz[200001],n,ct=0,x;
    f>>n;
    for(int i=0;i<n;i++)
    {
        char op;
        f>>op;
        if (op=='1')
        {
            f>>x;
            poz[++ct]=x;
            heap.insert(x);
        }
        else if(op=='2')
            {
                f>>x;
                heap.erase(poz[x]);
            }
        else
            {
                g<<*heap.begin()<<'\n';
            }
    }
    return 0;
}