Cod sursa(job #3265874)

Utilizator MrPuzzleDespa Fabian Stefan MrPuzzle Data 3 ianuarie 2025 19:38:40
Problema Heapuri Scor 100
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.65 kb
#include <bits/stdc++.h>

#define DIM 200000

using namespace std;

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

//ifstream f("filesmodel.in");
//ofstream g("filesmodel.out");

int n;
int c,x;
int v[DIM+5],k = 0;
map<int,int> mp;

signed main(){

    f>>n;

    while(n--){
        f>>c;
        if(c == 1){
            f>>x;
            v[++k] = x;
            mp[x]++;
        }else if(c==2){
            f>>x;
            x = v[x];
            mp[x]--;
            if(!mp[x]){
                mp.erase(x);
            }
        }else{
            g<<(*mp.begin()).first<<'\n';
        }
    }

    return 0;
}