Cod sursa(job #2361313)

Utilizator andreigeorge08Sandu Ciorba andreigeorge08 Data 2 martie 2019 14:29:01
Problema Heapuri Scor 100
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.6 kb
#include <bits/stdc++.h>

using namespace std;

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

set <int> heap;
vector <int> order;

int n;

int main()
{
    int op, x;

    fin >> n;
    for(int i = 1; i <= n; i++)
    {
        fin >> op;
        if(op == 1)
        {
            fin >> x;
            heap.insert(x);
            order.push_back(x);
        }
        else if(op == 2)
        {
            fin >> x;
            heap.erase(order[x - 1]);
        }
        else
        {
            fout << *heap.begin() << "\n";
        }
    }

    return 0;
}