Cod sursa(job #3120872)

Utilizator unomMirel Costel unom Data 9 aprilie 2023 00:51:18
Problema Heapuri Scor 100
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.58 kb
#include <fstream>
#include <set>
#include <vector>

using namespace std;

ifstream f("heapuri.in");
ofstream g("heapuri.out");
int n;
multiset <int> s;
vector <int> v;

int main()
{
    f>>n;
    int c, x;
    while(n--)
    {
        f>>c;
        if(c == 1)
        {
            f>>x;
            s.insert(x);
            v.push_back(x);
        }
        else if(c == 2)
        {
            f>>x;
            x = x - 1;
            s.erase(s.find(v[x]));
        }
        else
        {
            g<<*s.begin()<<'\n';
        }
    }
    return 0;
}