Pagini recente » Profil M@2Te4i | Istoria paginii prosoft-2017/clasament/1112 | Cod sursa (job #163387)
Cod sursa(job #163387)
const nmax=30000;
var v:array[1..nmax] of -25000..25000;
i,n,k,j,l,x,y:0..30000;
s,max:longint; f,g:text;
begin
assign(f,'secv2.in');
assign(g,'secv2.out');
reset(f);
rewrite(g);
readln(f,n,k);
for i:=1 to n do
read(f,v[i]);
max:=-25000;
for i:= 1 to n-1 do begin
j:=i; l:=0; s:=0;
repeat
s:=s+v[j];
l:=l+1;
if (s>=max) and (l>k) then begin
max:=s; x:=i;
y:=j;
end;
j:=j+1;
until j>=n;
writeln;
end;
write(g,x,' ', y, ' ',max);
close(g);
close(f);
end.
begin