Cod sursa(job #3251309)

Utilizator inacioataCioata Ana Irina inacioata Data 25 octombrie 2024 18:09:49
Problema Heapuri Scor 100
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.69 kb
#include <bits/stdc++.h>
using namespace std;

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

int main()
{
    int i = 0, j, T, op, x;
    ifstream fin("heapuri.in");
    ofstream fout("heapuri.out");
    fin >> T;
    while (T--)
    {
        fin >> op;
        if (op == 1)
        {
            fin >> x;
            i++;
            M[i] = x;
            s.insert(x);
        }
        else if (op == 2)
        {
            fin >> j;
            x = M[j];
            it = s.find(x);
            s.erase(it);
        }
        else /// op = 3
        {
            it = s.begin();
            fout << *it << "\n";
        }
    }
    return 0;
}