Cod sursa(job #2184074)

Utilizator PopeangaMihneaPopeanga Mihnea- Stefan PopeangaMihnea Data 23 martie 2018 18:11:15
Problema Heapuri Scor 100
Compilator cpp Status done
Runda Arhiva educationala Marime 0.54 kb
#include <bits/stdc++.h>

using namespace std;

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

set<int>heap;
int poz[200001];
int n, op, val, pos, t;

int main()
{
    fin>>t;
    for(int q=1; q<=t; ++q)
    {
        fin>>op;
        if(op==3) fout<<*heap.begin()<<"\n";
        else if(op==1)
        {
            fin>>val;
            heap.insert(val);
            poz[++n]=val;
        }
        else
        {
            fin>>pos;
            heap.erase(poz[pos]);
        }
    }
    return 0;
}