Cod sursa(job #2368699)

Utilizator RussianSmoothCriminalRodion Raskolnikov RussianSmoothCriminal Data 5 martie 2019 17:18:41
Problema Heapuri Scor 100
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.72 kb
#include <fstream>
#include <set>
#include <unordered_map>
using namespace std;

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

multiset <int> s;
multiset <int> :: iterator it;
unordered_map<int, int> M;

void Solve ()
{
    int n, pos = 0, op, x;
    fin >> n;
    while (n--)
    {
        fin >> op;
        if (op == 1)
        {
            fin >> x;
            M[++pos] = x;
            s.insert(x);
        }
        else if (op == 2)
        {
            fin >> x;
            s.erase(M[x]);
        }
        else
        {
            it = s.begin();
            fout << *it << "\n";
        }
    }
    fout.close();
}

int main()
{
    Solve();
    return 0;
}