Pagini recente » Cod sursa (job #120523) | Cod sursa (job #1402108) | Cod sursa (job #58873) | Cod sursa (job #63594) | Cod sursa (job #38623)
Cod sursa(job #38623)
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;
if k=0 then
begin
writeln(fo,0);
close(fo);
end;
max:=-maxlongint;
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.