记录编号 20459 评测结果 AAAAWWWWWW
题目名称 逛街 最终得分 40
用户昵称 Gravatar1102 是否通过 未通过
代码语言 Pascal 运行时间 0.704 s
提交时间 2010-10-26 09:16:47 内存使用 116.21 MiB
显示代码纯文本
program xxxx;
var i,i1,i2,n,x,v,h:longint;
    a:array[1..300,1..6] of longint;
    f:array[0..1000,0..100,0..300] of longint;

function max(a,b,c:longint):longint;
begin
  if (a>=b)and(a>=c) then
    max:=a;
  if (b>=a)and(b>=c) then
    max:=b;
  if (c>=a)and(c>=b) then
    max:=c;
end;


begin
  assign(input,'shop.in');
  reset(input);
  assign(output,'shop.out');
  rewrite(output);
  read(n,x,v);
  for i:=1 to n do
    begin
      read(a[i,1],a[i,2],a[i,3],h);
      a[i,4]:=a[i,1]*h;
      a[i,5]:=a[i,2]*h;
      a[i,6]:=a[i,3]*h;
    end;
  for i:=1 to x do
    for i1:=1 to v do
      for i2:=1 to n do
        begin
          if (i-a[i2,1]>=0)and(i1-a[i2,2]>=0) then
            f[i,i1,i2]:=max(f[i,i1,i2],f[i-a[i2,1],i1-a[i2,2],i2-1]+a[i2,3],f[i,i1,i2-1]);
          if (i-a[i2,4]>=0)and(i1-a[i2,5]>=0) then
            f[i,i1,i2]:=max(f[i,i1,i2],f[i-a[i2,4],i1-a[i2,5],i2-1]+a[i2,6],f[i,i1,i2-1]);
        end;
  h:=0;
  for i:=1 to x do
    for i1:=1 to v do
      for i2:=1 to n do
        if f[i,i1,i2]>h then
          h:=f[i,i1,i2];
  write(h);
  close(input);
  close(output);
end.