Cod sursa(job #3174969)

Utilizator matei__bBenchea Matei matei__b Data 25 noiembrie 2023 11:10:00
Problema Heapuri Scor 40
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 1.29 kb
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define chad char
#define mod 1000000007 
#define dim 100005
#define lim 1000000
#define mdim 1501
#define mult 2e9
#define maxx 200002
#define simaimult 1e17
#define FOR(i,a,b) for(int i=(a); i<=(b); i++)
#define pli pair<ll,int>
#define pil pair<int,ll>
#define piii pair<int,pair<int,int> > 
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pb push_back
#define mp make_pair
#define nr_biti __builtin_popcount
using namespace std;
 
ifstream fin("heapuri.in");
ofstream fout("heapuri.out");

//priority_queue<int,vector<int>,greater<int> > pq;
multiset<int> pq;

int q;
int v[2*dim],n;

int main()
{
    ios_base::sync_with_stdio(false);
    fin.tie(nullptr);
    fout.tie(nullptr);

    fin >> q;

    while(q--)
    {
        int tip;

        fin >> tip;

        if(tip==1)
        {
            ++n;
            fin >> v[n];

            pq.insert(v[n]);
        }
        else if(tip==2)
        {
            int x;

            fin >> x;

            multiset<int> ::iterator it=lower_bound(pq.begin(),pq.end(),v[x]);

            pq.erase(it);
        }
        else 
        {
            fout << *(pq.begin()) << "\n";
        }
    }

    return 0;
}