Cod sursa(job #2745898)

Utilizator andreinovaNacu Andrei Emilian andreinova Data 27 aprilie 2021 09:17:53
Problema Heapuri Scor 40
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.56 kb
#include <bits/stdc++.h>

using namespace std;

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


set<int> heap;

int n,i,caz,x,j=1;
int p[200001];

int main()
{
    in>>n;
    for (i=1;i<=n;i++)
	{
        in>>caz;

        if(caz!=3)
           in>>x;

        if (caz==1)
        {
            heap.insert(x);
            p[j++]=x;
        }

        else
        {
            if (caz==2)
                heap.erase(p[x]);

            else
              out<<*heap.begin()<<endl;
        }
    }

    return 0;
}