Pagini recente » Cod sursa (job #3136612) | Cod sursa (job #310022) | Cod sursa (job #49414) | Cod sursa (job #526076) | Cod sursa (job #49973)
Cod sursa(job #49973)
var a:array[1..50] of integer;
k,n,i,sc,pc,ic,sf,max:longint;
f,g:text;
begin
assign(f,'secv2.in'); reset(f);
assign(g,'secv2.out'); rewrite(g);
read(f,n,k);
for i:=1 to n do read(f,a[i]);
max:=a[1];
sc:=a[1];
ic:=1;
sf:=1;
pc:=1;
for i:=2 to n do begin
if sc>0 then sc:=sc+a[i]
else begin
sc:=a[i];
pc:=i;
end;
if (sc>max) and (i-pc+1>=k) then begin
ic:=pc;
sf:=i;
max:=sc;
end;
end;
write(g,ic,' ',sf,' ',max);
close(g);
end.