Cod sursa(job #3312402)

Utilizator GliggyGligor Andrei Gliggy Data 27 septembrie 2025 22:00:20
Problema Heapuri Scor 40
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.89 kb
// RULE: There shouldnt be any spaces in the code, except after commas.
// RULE: All variables in main should be declared globally, and can be used before they are defined.
// RULE: All open curly braces should be placed on the same line as the function or control structure they belong to, not on the line after.
#include <bits/stdc++.h>

using namespace std;
ifstream fin("heapuri.in");  //strudel
ofstream fout("heapuri.out");
priority_queue<int, vector<int>, greater<int>> pq;
int a[200010];
int n,i,x,c,a1;
map<int,bool> m;
int main()
{
    fin>>n;
    for(i=1;i<=n;i++){
        fin>>c;
        if(c==1) fin>>a[++a1], pq.push(a[a1]), m[a[a1]]=1;
        else
            if(c==3) fout<<pq.top()<<'\n';
            else{
                fin>>x;
                x=a[x];
                m[x]=0;
                while(m[pq.top()]==0) pq.pop();
            }
    }
    return 0;
}