Cod sursa(job #1611887)

Utilizator tudormaximTudor Maxim tudormaxim Data 24 februarie 2016 15:54:08
Problema Heapuri Scor 100
Compilator cpp Status done
Runda Arhiva educationala Marime 0.66 kb
#include <iostream>
#include <fstream>
#include <set>
using namespace std;

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

const int nmax = 200005;
set <int> heap;

int main()
{
    ios_base::sync_with_stdio(false);
    int n, op, x, ord[nmax], i, dim=0;
    fin >> n;
    for(i=1; i<=n; i++)
    {
        fin >> op;
        if(op==1)
        {
            fin >> x;
            ord[++dim]=x;
            heap.insert(x);
        }
       else if(op==2)
        {
            fin >> x;
            heap.erase(ord[x]);
        }
        else fout << *heap.begin() << "\n";
    }
    fin.close();
    fout.close();
    return 0;
}