Cod sursa(job #1732856)

Utilizator jurjstyleJurj Andrei jurjstyle Data 22 iulie 2016 18:46:50
Problema Heapuri Scor 100
Compilator cpp Status done
Runda Arhiva educationala Marime 0.55 kb
#include <fstream>
#include <set>
#include <vector>

using namespace std ;

ifstream f ("heapuri.in") ;
ofstream g ("heapuri.out") ;

multiset <int> H ;
vector <int> V ;
int N ;

int main ()
{
 f >> N ;
 for ( ; N ; --N )
    {
     int tip , x ;
     f >> tip ;
     if ( tip == 1 )
        {
         f >> x ;
         V.push_back ( x ) ;
         H.insert ( x ) ;
        }
     if ( tip == 2 )
        {
         f >> x ;
         H.erase ( V[x-1] ) ;
        }
     if ( tip == 3 )
        g << *H.begin()  << "\n" ;
    }
}