Cod sursa(job #797865)

Utilizator romircea2010FMI Trifan Mircea Mihai romircea2010 Data 15 octombrie 2012 01:17:22
Problema Heapuri Scor 100
Compilator cpp Status done
Runda Arhiva educationala Marime 0.67 kb
#include <fstream>
#include <set>

using namespace std;

int poz[200010], n, nr;
set<int> heap;

int main()
{
    ifstream f("heapuri.in");
    ofstream g("heapuri.out");
    f>>n;
    int x, cod;
    set<int>::iterator it;
    while(n--)
    {
        f>>cod;
        if(cod == 3)
        {
            it = heap.begin();
            g<<*it<<"\n";
        }
        else
        {
            f>>x;
            if(cod == 1)
            {
                heap.insert(x);
                nr++;
                poz[nr] = x;
            }
            else
                heap.erase(poz[x]);
        }
    }
    f.close();
    g.close();
    return 0;
}