直接费用流,天数就是点数
type arr=record toward,next,cap,cost:longint; end;const maxm=200000; maxn=200; mm=1<<30;var edge:array[0..maxm]of arr; first,slack,d:array[0..maxn]of longint; chose:array[0..maxn]of boolean; n,maxflow,maxcost,s,t,tot,esum:longint; function min(x,y:longint):longint;begin if x=0 do begin too:=edge[i].toward; value:=edge[i].cost; if (edge[i].cap>0) and (not chose[too]) then if d[x]=d[too]+value then begin more:=aug(too,min(flow-now,edge[i].cap)); dec(edge[i].cap,more); inc(edge[i xor 1].cap,more); inc(now,more); if flow=now then exit(flow); end else slack[too]:=min(slack[too],d[too]+value-d[x]); i:=edge[i].next; end; exit(now);end; function rel:boolean;var i,spent:longint;begin spent:=maxlongint; for i:=1 to tot do if not chose[i] then spent:=min(spent,slack[i]); if spent>=mm then exit(false); for i:=1 to tot do if chose[i] then inc(d[i],spent); exit(true);end; procedure into;var i,j,k,m,sum:longint;begin esum:=-1; fillchar(first,sizeof(first),255); readln(n,m,sum); tot:=n+2; s:=tot-1; t:=tot; for i:=1 to n do begin read(j); addedge(i,t,j,0); end; for i:=1 to n do begin read(j); addedge(s,i,maxlongint,j); end; for i:=1 to n-1 do addedge(i,i+1,sum,m);end; begin into; fillchar(d,sizeof(d),0); maxflow:=0; maxcost:=0; repeat fillchar(slack,sizeof(slack),$7f); repeat fillchar(chose,sizeof(chose),false); until aug(s,maxlongint)<=0; until not rel; writeln(maxcost); readln; readln;end.