Cod sursa(job #1360259)

Utilizator bogobatBerbece Daniel bogobat Data 25 februarie 2015 13:19:27
Problema Heapuri Scor 100
Compilator cpp Status done
Runda Arhiva educationala Marime 0.6 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);
    scanf("%d",&n);
    int x;
    for(n;n>0;n--){
        scanf("%d",&op);
        if(op==1){
            scanf("%d",&x);
            poz[++nr]=x;
            heap.insert(x);
        }
        else if(op==2){
            scanf("%d",&x);
            heap.erase(heap.find(poz[x]));
        }
        else printf("%d \n",*heap.begin());
    }
    return 0;
}