Cod sursa(job #1148597)

Utilizator dumytruKana Banana dumytru Data 20 martie 2014 21:56:40
Problema Heapuri Scor 100
Compilator cpp Status done
Runda Arhiva educationala Marime 0.63 kb
#include <iostream>
#include <fstream>
#include <vector>
#include <set>
#include <algorithm>
#include <utility>

using namespace std;

set <int> heap;

unsigned enter[200001];

int main()
{
    ifstream f("heapuri.in");
    ofstream g("heapuri.out");
    unsigned t;
    int r,i,x=1,n;
    f>>n;
    for(i=1;i<=n;i++)
    {
        f>>t;
        if(t==3)g<<*heap.begin()<<'\n';
        else if(t==2)
        {
            f>>r;
            heap.erase(enter[r]);
        }
        else if(t==1)
        {
            f>>r;
            heap.insert(r);
            enter[x++]=r;
        }
    }
    return 0;
}