Cod sursa(job #7961)

Utilizator bacerandreiBacer Andrei bacerandrei Data 23 ianuarie 2007 14:57:19
Problema Secventa Scor 10
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.46 kb
#include<fstream.h>
#define max 10001
long int a[max],n,i,k,ic,sf,j=1,min=1000000001,min1=-1000000001;
int main()
{
  ifstream f("secventa.in");
  ofstream g("secventa.out");
   f>>n>>k;
  for(i=1;i<=n;i++)
   f>>a[i];
  while(j<=n-k+1)
   {
    min=a[j];
     for(i=j;i<j+k;i++)
      if(a[i]<min)
       min=a[i];
    if(min>min1)
     {
      min1=min;
      ic=j;
      sf=j+k-1;
     }
   j++;
  }
  g<<ic<<" "<<sf<<" "<<min1;
return 0;
}