Pagini recente » Cod sursa (job #1903466) | Cod sursa (job #2853319) | Cod sursa (job #932913) | Cod sursa (job #21674) | Cod sursa (job #21237)
Cod sursa(job #21237)
var a:array[0..50] of integer;
k,n,i,max,min,pozmax,pozmin:longint;
f,g:text;
procedure citire;
begin
read(f,n,k);
readln(f);
a[0]:=0;
for i:=1 to n do begin
read(f,a[i]);
a[i]:=a[i-1]+a[i];
end;
end;
begin
assign(f,'secv2.in'); reset(f);
assign(g,'secv2.out'); rewrite(g);
citire;
max:=a[1];
min:=a[i];
for i:=2 to n do begin
if a[i]>max then begin
max:=a[i];
pozmax:=i;
end;
if a[i]<min then begin
min:=a[i];
pozmin:=i;
end;
end;
if (pozmin<pozmax) and (pozmax-pozmin+1>=k) then write(g,pozmin+1,' ',pozmax,' ',a[pozmax]-a[pozmin])
else write(g,'0 ',pozmax,' ',a[pozmax]);
close(g);
end.