记录编号 20481 评测结果 AAAAAAAAAA
题目名称 逛街 最终得分 100
用户昵称 Gravatar王者自由 是否通过 通过
代码语言 Pascal 运行时间 1.308 s
提交时间 2010-10-26 13:08:44 内存使用 58.16 MiB
显示代码纯文本
program shop;
type thing=record
  w,v,t,h:word;
end;
var n,x,y,i,j,k:word;
  a:array[1..300]of thing;
  f:array[0..300,0..1000,0..100]of word;
function max(a,b:word):word;
begin
  if a>b then exit(a) else exit(b);
end;
begin
  assign(input,'shop.in'); reset(input);
  assign(output,'shop.out'); rewrite(output);
  readln(n,x,y);
  for i:=1 to n do with a[i] do readln(w,v,t,h);
  fillchar(f,sizeof(f),0);
  for i:=1 to n do
    for j:=1 to x do
      for k:=1 to y do with a[i] do
        if (w<=j)and(v<=k) then
        begin
          f[i,j,k]:=max(f[i-1,j,k],f[i-1,j-w,k-v]+t);
          if (w*h<=j)and(v*h<=k) then
            f[i,j,k]:=max(f[i,j,k],f[i-1,j-w*h,k-v*h]+t*h);
        end else f[i,j,k]:=f[i-1,j,k];
  writeln(f[n,x,y]);
  close(input); close(output);
end.