Cod sursa(job #2745899)

Utilizator andreinovaNacu Andrei Emilian andreinova Data 27 aprilie 2021 09:22:26
Problema Heapuri Scor 100
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.52 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 v[200001];

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

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

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

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

        else if (caz==3)
          out << *heap.begin() << "\n";

    }

    return 0;
}