Cod sursa(job #2396674)

Utilizator Leonard123Mirt Leonard Leonard123 Data 3 aprilie 2019 18:42:44
Problema Heapuri Scor 20
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.72 kb
#include <fstream>
using namespace std;
ifstream cin("heapuri.in");
ofstream cout("heapuri.out");
#define maxn 200000
int heap[maxn],N,o,x,poz=0,mi=2000000000,poz2;
int main()
{
    cin>>N;
    for(int i=1; i<=N; i++){
        cin>>o;
        if(o==3){
            if(heap[poz2]==0){
                mi=2000000000;
                for(int i=1; i<=poz; i++)
                    if(heap[i]<mi&&heap[i]!=0){
                        mi=heap[i];
                        poz2=i;
                    }
            }
        cout<<mi<<'\n';
        }else if(o==2){
            cin>>x;
            heap[x]=0;
        }
        else {
            cin>>x;
            heap[++poz]=x;
        }
    }
    return 0;
}