Cod sursa(job #23711)

Utilizator LRRTLapi dej LRRT Data 1 martie 2007 11:07:46
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.