Cod sursa(job #3284529)

Utilizator crina2120Arnautu Cristina-Crina crina2120 Data 11 martie 2025 19:16:01
Problema Heapuri Scor 100
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.62 kb
#include <bits/stdc++.h>
using namespace std;

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

int n, v[200003], k;
multiset <int> a;

int main()
{
    ios_base::sync_with_stdio(0);
    fin.tie(0);
    fout.tie(0);
    int op, x;
    fin >> n;
    while (n--)
    {
        fin >> op;
        if (op == 1)
        {
            fin >> x;
            a.insert(x);
            v[++k] = x;
        }
        else if (op == 2)
        {
            fin >> x;
            a.erase(a.find(v[x]));
            v[x] = 0;
        }
        else fout << *a.begin() << "\n";
    }
    return 0;
}