Pagini recente » Cod sursa (job #855561) | Cod sursa (job #231882) | Cod sursa (job #2674683) | Cod sursa (job #2396750) | Cod sursa (job #261252)
Cod sursa(job #261252)
var f,g:text;
var
s1,i,n,j,s,max,k,x,p,r,o:longint;
begin
assign(f,'secv2.in');
reset(f);
assign(g,'secv2.out');
rewrite(g);
readln(f,n,k);
s:=-200000000;
r:=1;
for i:=1 to n do
begin
read(f,x);
s1:=s1+x;
if s+x<x then begin
if (s>max)and (i-1-r>=k) then
begin
p:=r;
o:=i-1;
max:=s;
end;
s:=x;
r:=i;
end
else
begin
s:=s+x;
if (s>max)and (i-r>=k) then
begin
p:=r;
o:=i;
max:=s;
end;
end;
end;
if n=k then begin
o:=n;
p:=1;
max:=s1;
end;
writeln(g,p,' ',o,' ',max);
close(g);
end.