Cod sursa(job #3357806)

Utilizator TestLicenta123Test Test TestLicenta123 Data 13 iunie 2026 15:07:15
Problema Heapuri Scor 100
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.69 kb
#include <fstream>
#include <vector>
#include <set>

int main() {
    std::ifstream input("heapuri.in");
    std::ofstream output("heapuri.out");

    int n;
    input >> n;

    std::vector<int> order;
    std::multiset<int> multiset;
    int op, x;
    while (n--) {
        input >> op;
        if (op == 1) {
            input >> x;
            order.push_back(x);
            multiset.insert(x);
        } else if (op == 2) {
            input >> x;
            auto it = multiset.find(order[x-1]);
            if (it != multiset.end()) {
                multiset.erase(it);
            }
        } else if (op == 3) {
            output << *multiset.begin() << '\n';
        }
    }

    return 0;
}