Cod sursa(job #2866699)

Utilizator tomaionutIDorando tomaionut Data 9 martie 2022 21:48:14
Problema Heapuri Scor 100
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.6 kb
#include <bits/stdc++.h>

using namespace std;

ifstream fin("heapuri.in");
ofstream fout("heapuri.out");
int op, q, n, a[200005], x;
multiset <int> M;
multiset <int> ::iterator it;
int main()
{
    fin >> q;
    while (q--)
    {   
        fin >> op;
        if (op == 1)
        {
            fin >> x;
            M.insert(x);
            a[++n] = x;
        }
        else if (op == 2)
        {
            fin >> x;
            M.erase(a[x]);
        }
        else
        {
            it = M.begin();
            fout << *it << "\n";
        }
    }

    return 0;
}