Cod sursa(job #2566489)

Utilizator NotTheBatmanBruce Wayne NotTheBatman Data 2 martie 2020 21:40:54
Problema Heapuri Scor 100
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.77 kb
#include <fstream>
#include <iostream>
#include <set>

using namespace std;

const int N = 2e5 + 5;

int ord[N], n;
multiset <int> s;
multiset <int> :: iterator it;
void Read ()
{
    ifstream fin ("heapuri.in");
    ofstream fout ("heapuri.out");
    fin >> n;
    int k = 0, op, x;
    while (n--)
    {
        fin >> op;
        if (op == 1)
        {
            fin >> x;
            k++;
            ord[k] = x;
            s.insert(x);
        }
        else if (op == 2)
        {
            fin >> x;
            s.erase(s.find(ord[x]));
        }
        else
        {
            it = s.begin();
            fout << *it << "\n";
        }
    }
    fout.close();
    fin.close();
}


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