Cod sursa(job #973274)

Utilizator EhtRalpmetFMI Ardei Claudiu-Alexandru EhtRalpmet Data 13 iulie 2013 21:25:27
Problema Secventa Scor 30
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.63 kb
#include <iostream>
#include <fstream>

using namespace std;
ifstream f("secventa.in");
ofstream g("secventa.out");

signed int i,v[500000],k,n,pozmin,bazamax= -30000,m;

signed int baza(int a)
{
    m=30000;
    for(;a<=i;a++)
        if(v[a]<m)
            m=v[a];
    return m;
}

int main()
{
    f>>n>>k;
    for(i=0;i<k-1;i++)
        f>>v[i];
    for(i=k-1;i<n;i++)
    {
        f>>v[i];
        if(v[i]>bazamax)
            if(baza(i-k+1)>bazamax)
            {
                pozmin=i-k+1;
                bazamax=m;
            }
    }
    g<<pozmin+1<<' '<<pozmin+k<<' '<<bazamax;

    return 0;
}