Cod sursa(job #2548237)

Utilizator Tudor06MusatTudor Tudor06 Data 16 februarie 2020 13:51:07
Problema Heapuri Scor 100
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.64 kb
#include <fstream>
#include <iostream>
#include <vector>
#include <set>

using namespace std;

const int NMAX = 200000;

set <int> heap;
vector <int> poz;

int main() {
    ifstream fin( "heapuri.in" );
    ofstream fout( "heapuri.out" );
    int n, cer, i, x;
    fin >> n;
    for ( i = 0; i < n; i ++ ) {
        fin >> cer;
        if ( cer == 1 ) {
            fin >> x;
            heap.insert( x );
            poz.push_back( x );
        } else if ( cer == 2 ) {
            fin >> x;
            heap.erase( poz[x - 1] );
        } else {
            fout << *( heap.begin() ) << '\n';
        }
    }
    return 0;
}