Cod sursa(job #2970242)

Utilizator sandry24Grosu Alexandru sandry24 Data 24 ianuarie 2023 18:41:18
Problema Heapuri Scor 100
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.88 kb
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pi;
#define pb push_back
#define mp make_pair
#define f first
#define s second
 
void solve(){
    int n;
    cin >> n;
    multiset<int> s;
    int a[n], ind = 0;
    for(int i = 0; i < n; i++){
        int c;
        cin >> c;
        if(c == 1){
            int x;
            cin >> x;
            s.insert(x);
            a[ind] = x;
            ind++;
        } else if(c == 2){
            int x;
            cin >> x;
            s.erase(a[x-1]);
        } else {
            cout << *s.begin() << '\n';
        }
    }
}  
 
int main(){
    freopen("heapuri.in", "r", stdin);
    freopen("heapuri.out", "w", stdout);
    ios::sync_with_stdio(0); cin.tie(0);
    int t = 1;
    //cin >> t;
    while(t--){
        solve();
    }
}