Cod sursa(job #57386)
Utilizator | Grosu Andrei Nicolae gozman | Data | 1 mai 2007 22:00:30 |
---|---|---|---|
Problema | Secventa 2 | Scor | 0 |
Compilator | fpc | Status | done |
Runda | Arhiva de probleme | Marime | 0.69 kb |
program secv2;
var x,s,inc,sf,smax,i,pinc,n,k:integer;
f:text;
begin
assign(f,'secv2.in'); reset(f);
readln(f,n,k);
pinc:=1; s:=0;
for i:= 1 to n do
begin
read(f,x);
if (s+x<x)and(i-pinc+1>=k) then
begin s:=x;pinc:=i; end
else s:=s+x;
if i-pinc+1>=k then
if s>smax then
begin
smax:=s;
inc:=pinc;
sf:=i;
end;
end;
close(f);
assign(f,'secv2.out'); rewrite(f);
writeln(f,inc,' ',sf,' ',smax);
close(f);
end.