Cod sursa(job #1360254)

Utilizator bogobatBerbece Daniel bogobat Data 25 februarie 2015 13:16:49
Problema Heapuri Scor 40
Compilator cpp Status done
Runda Arhiva educationala Marime 0.56 kb
#include <iostream>
#include <fstream>
#include <set>
using namespace std;

multiset <int> heap;
int n,op;
int poz[200009];
int nr;
int main()
{
    freopen("heapuri.in", "r", stdin);
    freopen("heapuri.out", "w", stdout);
    cin>>n;
    int x;
    for(n;n>0;n--){
        cin>>op;
        if(op==1){
            cin>>x;
            poz[++nr]=x;
            heap.insert(x);
        }
        else if(op==2){
            cin>>x;
            heap.erase(heap.find(poz[x]));
        }
        else cout<<*heap.begin()<<endl;
    }
    return 0;
}