Cod sursa(job #2590852)

Utilizator niculaandreiNicula Andrei Bogdan niculaandrei Data 29 martie 2020 05:49:59
Problema Heapuri Scor 10
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.67 kb
#include <bits/stdc++.h>
#define N_MAX 200005

using namespace std;

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

int Q, type, x;
int N, v[N_MAX];
set < int > heap;

int main()
{
    fin >> Q;
    while (Q--)
    {
        fin >> type;
        if (type == 1)
        {
            fin >> x;
            v[++N] = x;
            heap.insert(x);
        }
        else if (type == 2)
        {
            fin >> x;
            heap.erase(lower_bound(heap.begin(), heap.end(), v[x]));
        }
        else if (type == 3)
        {
            fout << *lower_bound(heap.begin(), heap.end(), 0) << "\n";
        }
    }
    return 0;
}