Cod sursa(job #2326473)

Utilizator OveehMariciuc Ovidiu Oveeh Data 23 ianuarie 2019 16:26:15
Problema Heapuri Scor 100
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.6 kb
#include <iostream>
#include <fstream>
#include <algorithm>
#include <set>
#define nmax 200001

using namespace std;

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

int n,m,a[nmax];
set<int> heap;

int main()
{
    fin>>n;
    int op,x;
    for(int i=0; i<n; i++)
    {
        fin>>op;
        if(op==1)
        {
            fin>>x;
            heap.insert(x);
            a[m++]=x;
        }
        else if(op==2)
        {
            fin>>x;
            heap.erase(a[x-1]);
        }
        else
            fout<<*heap.begin()<<'\n';
    }
    return 0;
}