Cod sursa(job #1360250)

Utilizator bogobatBerbece Daniel bogobat Data 25 februarie 2015 13:14:12
Problema Heapuri Scor 40
Compilator cpp Status done
Runda Arhiva educationala Marime 0.52 kb
#include <iostream>
#include <fstream>
#include <set>
using namespace std;
ifstream f("heapuri.in");
ofstream g("heapuri.out");
multiset <int> heap;
int n,op;
int poz[200009];
int nr;
int main()
{
    f>>n;
    int x;
    for(n;n>0;n--){
        f>>op;
        if(op==1){
            f>>x;
            poz[++nr]=x;
            heap.insert(x);
        }
        else if(op==2){
            f>>x;
            heap.erase(heap.find(poz[x]));
        }
        else g<<*heap.begin()<<endl;
    }
    return 0;
}