Cod sursa(job #2742619)

Utilizator GhiuzanuEdward Ghiuzan Ghiuzanu Data 21 aprilie 2021 12:19:35
Problema Heapuri Scor 40
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.58 kb
#include <iostream>
#include <fstream>
#include <set>
using namespace std;

int main() {
    multiset<int> heap;
    ifstream fin("heapuri.in");
    ofstream fout("heapuri.out");
    int n, option, k = 0, x;
    fin>>n;
    int v[n + 1];
    for (int i = 0; i < n; ++i) {
        fin>>option;
        if(option == 3)
            fout<<*heap.begin()<<endl;
        else {
            fin >> x;
            if (option == 2)
                heap.erase(heap.find(v[x - 1]));
            else {
                heap.insert(x);
                v[k++] = x;
            }
        }
    }
    return 0;
}