Cod sursa(job #2044096)

Utilizator dnprxDan Pracsiu dnprx Data 20 octombrie 2017 21:36:12
Problema Heapuri Scor 100
Compilator cpp 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;
}