比赛 20101025 评测结果 AAAAAAAAAA
题目名称 逛街 最终得分 100
用户昵称 苏轼 运行时间 0.000 s
代码语言 Pascal 内存使用 0.00 MiB
提交时间 2010-10-25 20:09:34
显示代码纯文本
program shop(input,output);

type
  re=record
    w,v,t,h:integer;
  end;

var
  n,x,y,i,j,k:integer;
  th:array[1..300]of re;
  dym:array[0..300,0..1000,0..100]of integer;

function max(a,b:integer):integer;
  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
    readln(th[i].w, th[i].v, th[i].t, th[i].h);

  for i:=1 to n do
    for j:=1 to x do
      for k:=1 to y do
      begin
        if (th[i].w<=j)and(th[i].v<=k) then
        begin
          dym[i,j,k]:=max(dym[i-1,j,k],dym[i-1,j-th[i].w,k-th[i].v]+th[i].t);

          if (th[i].w*th[i].h<=j)and(th[i].v*th[i].h<=k) then
            dym[i,j,k]:=max(dym[i,j,k],dym[i-1,j-th[i].w*th[i].h,k-th[i].v*th[i].h]+th[i].t*th[i].h);
        end
        else
          dym[i,j,k]:=dym[i-1,j,k];
      end;

  writeln(dym[n,x,y]);

  close(input);
  close(output);
end.