Cod sursa(job #582671)
Utilizator | Oprea Valeriu-Florin FLORINSTELISTU | Data | 15 aprilie 2011 17:45:10 |
---|---|---|---|
Problema | Secventa 2 | Scor | 0 |
Compilator | fpc | Status | done |
Runda | Arhiva de probleme | Marime | 0.56 kb |
program secv2;
var f,g:text;n,k,st,sf,max,min,a,poz,i:int64;
s:array[0..50001]of int64;
begin
assign(f,'secv2.in');reset(f);
assign(g,'secv2.out');rewrite(g);
readln(f,n,k);
for i:=1 to n do begin
read(f,a);
s[i]:=s[i-1]+a;
if (max<s[i]-min)and(i-poz>=k) then begin
st:=poz+1;
sf:=i;
max:=s[i]-min;end;
if (s[i]<min)and(n-i>k) then begin
poz:=i;
min:=s[i];end;
end;
write(g,st,' ',sf,' ',max,' ');
close(g);close(f);
end.