Cod sursa(job #866881)

Utilizator FayedStratulat Alexandru Fayed Data 28 ianuarie 2013 20:53:39
Problema Heapuri Scor 0
Compilator cpp Status done
Runda Arhiva educationala Marime 0.99 kb
#include <fstream>
#include <algorithm>
#include <vector>
using namespace std;

 int n,cod,x,aux;
 int  V[200000];

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

int main(){

    f >> n;
    int k=0,j;
    for(int i=1;i<=n;i++){
        f >> cod;
            if(cod!=3){

                if(cod == 1){
                f >> x;
                 V[k] = x;
                k++;
                push_heap(V,V+k);

                }
               if(cod == 2) {
                f >> x;
                    for(j=0;j<k;j++)
                        if(V[j] == x){
                            aux = j;
                            break;
                            }
                        for(int z=aux;z<k-1;z++)
                        V[z] = V[z+1];
                        k--;
               }

            }
        else{

            sort_heap(V,V+k);
           g << V[0] << '\n';
        }
            }

    f.close();
    g.close();
    return 0;
}