Cod sursa(job #1916203)

Utilizator sculap1234321Panainte Alexandru sculap1234321 Data 9 martie 2017 08:34:48
Problema Heapuri Scor 40
Compilator cpp Status done
Runda Arhiva educationala Marime 1.07 kb
#include <bits/stdc++.h>

using namespace std;
int st[2000003], top, k, n;
int a[2000003];
void Sterge(int x)
{
    int i;
    for(i = x; i < k; i++)
        a[i] = a[i+1];
}
int Find(int x)
{
   int i;
   for(i = 1; i <= k; i++)
        if(a[i] == x)
        return i;
}
void Afisare()
{
    int i;
    for(i =1; i <= k; i++)
        cout<<a[i]<<" ";
    cout<<"\n";
}
void Citire()
{   int i, op, x, minim;
    int j;
    ifstream fin("heapuri.in");
    ofstream fout("heapuri.out");
    fin >> n;
    for(i = 1; i <= n; i++)
    {
        fin >> op;
        if(op == 1)
            {
                fin >> x;
                st[++top] = x;
                a[++k] = x;

            }
        else if(op == 2)
            {
                fin >> x;
                Sterge(Find(st[x]));
                k--;

            }
        else
        {   minim = a[1];
            for(j = 2; j <= k; j++)
                minim = min(minim, a[j]);
            fout << minim<<"\n";
        }
    }
}
int main()
{
    Citire();
    return 0;
}