Cod sursa(job #38556)

Utilizator floringh06Florin Ghesu floringh06 Data 25 martie 2007 21:37:14
Problema Secventa 2 Scor 70
Compilator fpc Status done
Runda Arhiva de probleme Marime 0.64 kb
{$IFDEF NORMAL}
  {$I-,Q-,R-,S-}
{$ENDIF NORMAL}
{$IFDEF DEBUG}
  {$I+,Q+,R+,S-}
{$ENDIF DEBUG}
{$IFDEF RELEASE}
  {$I-,Q-,R-,S-}
{$ENDIF RELEASE}

var fi,fo:text;
    i,j,n,k:word;
    vl,max,indi,indj:longint;
    s:array[0..50002] of longint;


begin
 assign(fi,'secv2.in'); reset(fi);
 assign(fo,'secv2.out'); rewrite(fo);
 readln(fi,n,k);
 for i:=1 to n do
  begin
   read(fi,vl);
   s[i]:=s[i-1]+vl;
  end;
 max:=-maxint;
 for i:=k to n do
  for j:=0 to i-k do
   if s[i]-s[j] > max then
    begin
     max:=s[i]-s[j];
     indi:=i;
     indj:=j+1;
    end;
 writeln(fo,indj,' ',indi,' ',max);
close(fo);
end.