Cod sursa(job #2739957)

Utilizator Tache_RoxanaTache Roxana Tache_Roxana Data 10 aprilie 2021 18:16:20
Problema Heapuri Scor 100
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.69 kb
#include <iostream>
#include <fstream>
#include <set>
using namespace std;

long long n, a, b, v[200001], z;

int main()
{
    ifstream in("heapuri.in");
    ofstream out("heapuri.out");
    in >> n;
    set <int> heap;
    heap.clear();
    for(int i = 0; i < n; i++)
    {
        in >> a;
        if( a == 1)
        {
            in >> b;
            v[z++] = b;
            heap.insert(b);
        }
        if(a == 3)
        {
            set<int>:: iterator it = heap.begin();
            out << *it << "\n";
        }
        if(a == 2)
        {
               in >> b;
               b--;
               heap.erase(v[b]);
        }
    }
    return 0;
}