Cod sursa(job #724524)

Utilizator horeste12Stoianovici Horatiu Andrei horeste12 Data 26 martie 2012 17:05:20
Problema Heapuri Scor 100
Compilator cpp Status done
Runda Arhiva educationala Marime 0.57 kb
#include <cstdio>
#include <set>
#include <vector>
using namespace std;

int n;
multiset <int> heap;
vector <int> pos;
int main()
{
    freopen("heapuri.in","r",stdin);
    freopen("heapuri.out","w",stdout);
    scanf("%d\n",&n);
    while(n--)
    {
        int opt;
        scanf("%d",&opt);
        int x;
        switch(opt)
        {
            case 3:printf("%d\n",*heap.begin());break;
            case 1:scanf("%d\n",&x);heap.insert(x); pos.push_back(x);break;
            case 2:scanf("%d\n",&x);heap.erase(heap.find(pos[x-1]));break;
        }
    }
    return 0;
}