Cod sursa(job #857076)

Utilizator Coman95coman cosmin Coman95 Data 17 ianuarie 2013 11:34:20
Problema Heapuri Scor 100
Compilator cpp Status done
Runda Arhiva educationala Marime 0.67 kb
#include <fstream>
#include <set>
#include <vector>
using namespace std;

ifstream fin("heapuri.in");
ofstream fout("heapuri.out");

set<int> s;
vector<int> poz;
int n;

int main()
{
    int x, y, k = 0;
    fin >> n;
    poz.resize( n + 1 );
    for( int i = 1; i <= n; ++i )
    {
        fin >> x;
        if( x == 3 )
        {
            fout << *s.begin() << '\n';
            continue;
        }
        if( x == 1 )
        {
            fin >> y;
            s.insert( y );
            poz[++k] = y;
            continue;
        }
        fin >> y;
        s.erase(poz[y]);
    }
    fin.close();
    fout.close();
    return 0;
}