Cod sursa(job #3324632)

Utilizator Luca_georgescuLuca Georgescu Luca_georgescu Data 22 noiembrie 2025 18:54:32
Problema Heapuri Scor 100
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.78 kb
#include <bits/stdc++.h>
#define pii pair <int,int>
#define fs first
#define sc second

using namespace std;

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

priority_queue < pii, vector<pii>, greater<pii> > pq;

const int nmax=2e5+5;
bool del[nmax];

int main()
{
    int q; f >> q;

    int idx=0;
    while ( q-- )
    {
        int cer; f >> cer;

        if ( cer==1 )
        {
            int x; f >> x;

            idx++;
            pq.push({x,idx});
        }
        else if ( cer==2 )
        {
            int x; f >> x;
            del[x]=true;
        }
        else
        {
            while ( !pq.empty() && del[pq.top().sc]==true )
                pq.pop();

            g << pq.top().fs << '\n';
        }
    }
    return 0;
}