Cod sursa(job #3131874)

Utilizator AndreiKatsukiAndrei Dogarel AndreiKatsuki Data 21 mai 2023 20:30:01
Problema Heapuri Scor 100
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.65 kb
#include <bits/stdc++.h>

using namespace std;

ifstream f("heapuri.in");
ofstream g("heapuri.out");

set<int> heap;
int n;

int main(){
    f >> n;
    vector<int> pushed;
    pushed.push_back(INT32_MIN);
    for(int i = 1; i <= n; ++i){
        int op;
        f >> op;
        if(op == 1){
            int x;
            f >> x;
            heap.insert(x);
            pushed.push_back(x);
        }
        else if(op == 2){
            int x;
            f >> x;
            heap.erase(pushed[x]);
            pushed[x] = INT32_MIN;
        }
        else{
            g << *heap.begin() << "\n";
        }
    }
    return 0;
}