Cod sursa(job #163387)

Utilizator iiipppPUSCASU ION iiippp Data 22 martie 2008 07:38:45
Problema Secventa 2 Scor 40
Compilator fpc Status done
Runda Arhiva de probleme Marime 0.55 kb
const nmax=30000;
var v:array[1..nmax] of -25000..25000;
i,n,k,j,l,x,y:0..30000;
s,max:longint;  f,g:text;
begin
assign(f,'secv2.in');
assign(g,'secv2.out');
reset(f);
rewrite(g);
readln(f,n,k);
for i:=1 to n do
read(f,v[i]);
 max:=-25000;
for i:= 1 to n-1 do begin
j:=i;   l:=0;    s:=0;
repeat
s:=s+v[j];
l:=l+1;
if  (s>=max) and (l>k) then begin
  max:=s;  x:=i;
              y:=j;
              end;
j:=j+1;
 until j>=n;
 writeln;
               end;
   write(g,x,' ', y, ' ',max);
   close(g);
   close(f);
   end.

begin