Pagini recente » Cod sursa (job #2661503) | Cod sursa (job #2082692) | Cod sursa (job #2044014) | Cod sursa (job #1134860) | Cod sursa (job #582805)
Cod sursa(job #582805)
var a,sum:array[0..6000000] of longint;
buf:array[1..100000000] of char;
n,i,j,min,s,t,x,y,best,k:longint;
sir:string;
f,g:text;
begin
assign(f,'secv2.in');
assign(g,'secv2.out');
reset(f);
settextbuf(f,buf);
rewrite(g);
readln(f,n,k);
s:=-1000000000;
y:=0;
for i:=1 to n do
begin
read(f,a[i]);
if a[i]>0 then t:=-1;
if a[i]>s then begin s:=a[i]; x:=i; end;
a[i]:=a[i]+a[i-1];
end;
if t=-1 then
begin
s:=-1000000000;
min:=1000000000;
x:=1;
for i:=1 to n do
begin
best:=a[i]-min;
if min>a[i] then begin t:=i+1; min:=a[i]; end;
if (s<best)and(i-t+1>=k) then begin s:=best; y:=i; x:=t; end;
end;
end;
if y=0 then y:=x;
write(g,x,' ',y,' ',s);
close(g);
end.