Cod sursa(job #2366898)

Utilizator qwerty1234qwerty qwerty1234 Data 4 martie 2019 22:44:34
Problema Heapuri Scor 100
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.72 kb

#include <bits/stdc++.h>


using namespace std;

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

multiset < pair < int , int > > Q;

multiset < pair < int , int > > :: iterator it;

unordered_map < int , int > M;

int q;

int main()
{
    int op , x , k = 0;
    fin >> q;
    while(q--)
    {
        fin >> op;
        if(op == 1)
        {
            fin >> x;
            Q.insert({x , ++k});
            M[k] = x;
        }
        else if(op == 2)
        {
            fin >> x;
            Q.erase(Q.find({M[x] , x}));
        }
        else
        {
            it = Q.begin();
            fout << it->first << "\n";
        }
    }
    fin.close();
    fout.close();
}