Cod sursa(job #2412012)

Utilizator Vlad_NituNitu Vlad-Petru Vlad_Nitu Data 21 aprilie 2019 15:55:20
Problema Heapuri Scor 100
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.6 kb
#include <bits/stdc++.h>
#define NMAX 200005
using namespace std;
ifstream f ("heapuri.in") ;
ofstream g ("heapuri.out") ;
int N ,cer , x , k = 0;
int poz[NMAX];
set <int> h; // min heap
int main()
{
    f >> N ;
    for (int i = 1 ; i <= N ; ++i)
    {
        f >> cer;
        if (cer == 1)
        {
            f >> x;
            h.insert(x) ;
            poz[++k] = x;
        }
        else if (cer == 2)
        {
            f >> x;
            h.erase(poz[x]) ;
        }
        else
            g << *h.begin() << '\n';
    }
    f.close();
    g.close();
    return 0 ;
}