Pagini recente » Cod sursa (job #2587962) | Cod sursa (job #2943162) | Cod sursa (job #70675) | Cod sursa (job #997305) | Cod sursa (job #509454)
Cod sursa(job #509454)
const f='secv2.in';g='secv2.out';
nmax=6000000;
var
v,s:array[0..nmax] of longint;
i,n,Smin,Smax,k,pmin,pmax:longint;
buf:array[1..1 shl 17] of char;
begin
assign(input,f);reset(input);
assign(output,g);rewrite(output);
settextbuf(input,buf);
readln(n,k);
s[0]:=0;
for i:=1 to n do
begin
read(v[i]);
s[i]:=s[i-1]+v[i];
end;
smin:=2000000000;
smax:=-2000000000;
for i:=k to n do
begin
if s[i-k]<smin then
begin
smin:=s[i-k];
pmin:=i-k;
end;
if s[i]-smin>smax then
begin
smax:=s[i]-smin;
pmax:=i;
end;
end;
writeln(pmin+1,' ',pmax,' ',smax);
{writeln(g,i1);
writeln(g,i2);
for i:=i1 to i2 do write(g,v[i],' ');
}
close(input);
close(output);
end.