Cod sursa(job #2214223)

Utilizator pacheprotopopescuPake Protopopescu pacheprotopopescu Data 18 iunie 2018 16:08:23
Problema Heapuri Scor 0
Compilator cpp Status done
Runda Arhiva educationala Marime 0.71 kb
#include <iostream>
#include <fstream>
using namespace std;
ifstream f("heapuri.in");
ofstream g("heapuri.out");
int n,x,v[200001],y,i,l=0,j,mn,poz;
int main()
{
    f>>n;
    for(i=1; i<=n; i++)
    {
        f>>y;
        if(y==1)
        {
            f>>x;
            l++;
            v[l]=x;
        }
        else if(y==2)
        {
            f>>x;
            if(x==l)l--;
            else
            {
                for(j=x; j<=l; j++)
                    v[j]=v[j+1];
                l--;
            }


        }
        else
        {
            mn=v[1];
            for(j=1; j<=l; j++)
                if(mn>v[j])mn=v[j];
            g<<mn<<"\n";
        }
    }
}