Cod sursa(job #3130429)

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

using namespace std;

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

    const string inputFile = "heapuri.in";
    const string outputFile = "heapuri.out";

public:

    void start() {
        ifstream fin(inputFile);
        ofstream fout(outputFile);
        int n, option, x;
        fin >> n;
        for (int i = 0; i < n; i++) {
            fin >> option;
            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;
                }
            }
        }
        fin.close();
        fout.close();
    }
};

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