细节理解题,注意体感有点问题,p只加一次
var codevs,poj:array[0..20] of longint; ans,ci,pi,n,k,p,i:longint; begin readln(n,k,p); for i:=1 to n do read(poj[i]); readln; for i:=1 to n do read(codevs[i]); for i:=2 to n do poj[i]:=poj[i]+poj[i-1]; for i:=2 to n do codevs[i]:=codevs[i]+codevs[i-1]; ans:=-maxlongint; for i:=0 to n-k do begin ci:=codevs[i+k]-codevs[i]; pi:=poj[i+k]-poj[i]; if ci-pi>ans then ans:=ci-pi; end; ans:=ans+1-p; if ans<0 then writeln(-1) else writeln(ans); end.
喜欢就收藏一下,vic私人qq:1064864324,加我一起讨论问题,一起进步^-^