Cod sursa(job #3132100)

Utilizator Andrei20035Rusu Andrei Andrei20035 Data 21 mai 2023 23:12:56
Problema Heapuri Scor 100
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.66 kb
#include <iostream>
#include <fstream>
#include <set>

using namespace std;

int main()
{
    ifstream in("heapuri.in");
    ofstream out("heapuri.out");

    int n, pos[200000], count = 1, aux;
    multiset<int> heap;

    in >> n;

    for (int i = 0; i < n; i++)
    {
        in >> aux;

        if (aux == 1)
        {
            in >> aux;
            pos[count] = aux;
            heap.insert(aux);
            count++;
        }
        else if (aux == 2)
        {
            in >> aux;
            heap.erase(pos[aux]);
        }
        else
        {
            out << *heap.begin() << endl;
        }
    }

    return 0;
}