记录编号 43636 评测结果 AAAAAAAAAAA
题目名称 [Freddy] 坏苹果 最终得分 100
用户昵称 GravatarVow Ryan 是否通过 通过
代码语言 Pascal 运行时间 0.009 s
提交时间 2012-10-12 07:22:12 内存使用 0.27 MiB
显示代码纯文本
var
 f,d,sum:array[0..30,0..300]of longint;
 a,s,di:array[0..30]of longint;
 i,j,k,l,m,n,ans:longint;

function max(a,b:longint):longint;
 begin
  if a>b then exit(a) else exit(b);
 end;

begin
 assign(input,'badapple.in');reset(input);
 assign(output,'badapple.out');rewrite(output);
 read(n,m);
 m:=m*12;
 for i:=2 to n do read(a[i]);
 for i:=1 to n do s[i]:=s[i-1]+a[i];
 for i:=1 to n do read(d[i,1]);
 for i:=1 to n do sum[i,1]:=d[i,1];
 for i:=1 to n do read(di[i]);
 
 
 for i:=1 to n do
  for j:=2 to m do
   begin
    d[i,j]:=max(d[i,j-1]-di[i],0);
    sum[i,j]:=sum[i,j-1]+d[i,j];
   end;
 for i:=1 to m do 
  begin
   f[1,i]:=sum[1,i];
   ans:=max(ans,f[1,i]);
  end;
 for i:=2 to n do
  for j:=s[i] to m do
   begin
    f[i,j]:=f[i-1,j-a[i]];
    for k:=0 to j-a[i] do
     f[i,j]:=max(f[i,j],f[i-1,k]+sum[i,j-k-a[i]]);
    f[i,j]:=max(f[i,j],f[i,j-1]);
    if f[i,j]>ans then ans:=f[i,j];
   end;
 writeln(ans);
 close(input);close(output);
end.