Cod sursa(job #3130430)

Utilizator omaclearuMacelaru Octavian Andrei omaclearu Data 17 mai 2023 19:40:16
Problema Heapuri Scor 100
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 1.01 kb
#include <iostream>
#include <fstream>
#include <set>
#include <vector>

using namespace std;

ifstream fin("heapuri.in");

ofstream fout("heapuri.out");

class HeapOperations {
private:
    multiset<int> heap;
    vector<int> v;
    int k = 0;

    void executeOption(int option) {
        int x;
        switch (option) {
            case 1: {
                fin >> x;
                heap.insert(x);
                v.push_back(x);
                break;
            }
            case 2: {
                fin >> x;
                heap.erase(v.at(x - 1));
                break;
            }
            case 3: {
                fout << *heap.begin() << "\n";
                break;
            }
        }

    }

public:

    void start() {
        int n, option;

        fin >> n;
        for (int i = 0; i < n; i++) {
            fin >> option;
            executeOption(option);

        }
        fin.close();
        fout.close();
    }
};

int main() {
    HeapOperations heapOps;
    heapOps.start();
    return 0;
}