Cod sursa(job #2691876)

Utilizator tomaionutIDorando tomaionut Data 30 decembrie 2020 13:48:25
Problema Heapuri Scor 40
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.64 kb
#include <bits/stdc++.h>

using namespace std;

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


    return 0;
}