Cod sursa(job #3282361)

Utilizator Tudor_EnacheEnache Tudor Tudor_Enache Data 5 martie 2025 11:52:51
Problema Heapuri Scor 100
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.51 kb
#include <fstream>
#include <set>
#include <vector>

std::ifstream fin("heapuri.in");
std::ofstream fout("heapuri.out");

std::multiset<int> s;
int i = 0;
int stack[200001];
int main(){

    int n; fin >> n;
    while(n--){
        int k;
        int x; fin >> x;
        if(x == 1){
            fin >> k;
            s.insert(k);
            stack[++i] = k; 
        }
        else if(x == 2){
            fin >> k;
            s.erase(s.find(stack[k])); 
        }
        else
            fout << *s.begin() << '\n';
    }
}