Cod sursa(job #1577117)

Utilizator AndreiGrigorasAndrei Grigoras AndreiGrigoras Data 23 ianuarie 2016 11:31:40
Problema Heapuri Scor 100
Compilator cpp Status done
Runda Arhiva educationala Marime 0.79 kb
#include <fstream>
#include <set>
#include <algorithm>

using namespace std;

ofstream fout ( "heapuri.out" ) ;
set<int> H ;
int n , op , value , timp[200200] , beg ;

void read()
{
    freopen ( "heapuri.in" , "r" , stdin ) ;
    scanf ( "%d" , &n ) ;
    for ( int i = 1 ; i <= n ; i++ )
    {
        scanf ( "%d" , &op ) ;
        {
            if ( op == 1 )
            {
                scanf ( "%d" , &value ) ;
                timp[++beg] = value ;
                H.insert(value) ;
            }
            if ( op == 2 )
            {
                scanf ( "%d" , &value ) ;
                H.erase(timp[value]) ;
            }
            if ( op == 3 )
                fout <<*H.begin() << '\n' ;
        }
    }
}
int main()
{
    read() ;
    return 0;
}