Pagini recente » Cod sursa (job #861135) | Cod sursa (job #2853157) | Cod sursa (job #38553)
Cod sursa(job #38553)
{$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,'secventa2.in'); reset(fi);
assign(fo,'secventa2.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.