Cod sursa(job #1257196)

Utilizator gerd13David Gergely gerd13 Data 7 noiembrie 2014 13:43:03
Problema Heapuri Scor 0
Compilator cpp Status done
Runda Arhiva educationala Marime 0.83 kb
#include <fstream>
#include <set>
#include <iostream>


using namespace std ;

const int NMAX = 200005 ;

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

int N ;
multiset <int> H ;
int ord[NMAX] ;
int main()
{
    fin >> N ;
    int cnt = 0 ;
    for(int i = 1 ; i <= N ; ++ i)
    {
        int x ;
        fin >> x ;
        if(x == 1)
        {
            int y ;
            fin >> y ;
            H.insert(y) ;
            ord[cnt] = y ;
            ++ cnt ;
        }
        else if(x == 2)
        {
            int y ;
            fin >> y ;
            H.erase(ord[y - 1]) ;
        }

        else if(x == 3)
        {
            multiset <int> :: iterator it = H.begin() ;
            fout << *it << '\n' ;
        }
    }


    fin.close() ;
    fout.close() ;
    return 0 ;
}