Pagini recente » Cod sursa (job #2980925) | Cod sursa (job #27938) | Cod sursa (job #392726) | Cod sursa (job #2790703) | Cod sursa (job #28800)
Cod sursa(job #28800)
var n,k,max,maxi,maxj,i:longint;
a:array[1..50]of integer;
p,s:array[1..50]of longint;
f,g:text;
begin
assign(f,'secv2.in');
reset(f);
readln(f,n,k);
read(f,a[1]);
p[1]:=a[1];
s[1]:=1;
max:=-maxint;
maxi:=1;
maxj:=1;
if k=1 then max:=a[1];
for i:=2 to n do begin
read(f,a[i]);
if p[i-1]>0 then begin
p[i]:=p[i-1]+a[i];
s[i]:=s[i-1];
end
else begin
p[i]:=a[i];
s[i]:=i;
end;
if p[i]>max then if i-s[i]+2>k then begin
max:=p[i];
maxi:=s[i];
maxj:=i;
end;
end;
assign(g,'secv2.out');
rewrite(g);
write(g,maxi,' ',maxj,' ',max);
close(g);
end.