Cod sursa(job #6720)
Utilizator | kis levente lorand kis_lori | Data | 20 ianuarie 2007 18:06:09 |
---|---|---|---|
Problema | Secventa 2 | Scor | 100 |
Compilator | fpc | Status | done |
Runda | Arhiva de probleme | Marime | 0.47 kb |
var s:array[0..50000] of longint;
n,k,i,pmax,pmin:longint;
begin
assign(input,'secv2.in'); reset(input);
assign(output,'secv2.out'); rewrite(output);
readln(n,k);
for i:=1 to n do begin
read(s[i]); inc(s[i],s[i-1]);
end;
pmax:=k;
for i:=k+1 to n do
if s[i]>s[pmax] then pmax:=i;
pmin:=pmax-k;
for i:=0 to pmin-1 do
if s[i]<s[pmin] then pmin:=i;
write(pmin+1,' ',pmax,' ',s[pmax]-s[pmin]);
close(input); close(output);
end.