Cod sursa(job #2738532)

Utilizator niculaandreiNicula Andrei Bogdan niculaandrei Data 5 aprilie 2021 23:53:53
Problema Heapuri Scor 100
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.58 kb
#include <bits/stdc++.h>

using namespace std;

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

const int N_MAX = 2e5 + 5;

int N, op, x;
int v[N_MAX], cnt;

multiset < int > US;

int main()
{
    fin >> N;
    for (int i = 1; i <= N; i++) {
        fin >> op;
        if (op == 1) {
            fin >> x;
            v[++cnt] = x;
            US.insert(x);
        }
        else if (op == 2) {
            fin >> x;
            US.erase(v[x]);
        }
        else {
            fout << *US.begin() << "\n";
        }
    }
    return 0;
}