比赛 |
20101025 |
评测结果 |
AAAAAAAAAA |
题目名称 |
逛街 |
最终得分 |
100 |
用户昵称 |
ybh |
运行时间 |
0.000 s |
代码语言 |
Pascal |
内存使用 |
0.00 MiB |
提交时间 |
2010-10-25 20:59:02 |
显示代码纯文本
{逛街}
{水题}
{yangbohua}
{time: 2010-10-25}
program shop;
var
f:array[0..1000,0..100] of longint;
c1,c2,w,h:array[0..300] of longint;
n,cost1,cost2,i,j1,j2:longint;
begin
assign(input,'shop.in');
reset(input);
assign(output,'shop.out');
rewrite(output);
readln(n,cost1,cost2);
for i:=1 to n do
readln(c1[i],c2[i],w[i],h[i]);
for i:=1 to n do
for j1:=cost1 downto c1[i] do
for j2:=cost2 downto c2[i] do
begin
if (h[i]=1) or (j1-c1[i]*h[i]<0) or (j2-c2[i]*h[i]<0) then
begin
if f[j1-c1[i],j2-c2[i]]+w[i]>f[j1,j2]
then f[j1,j2]:=f[j1-c1[i],j2-c2[i]]+w[i];
end
else
begin
if f[j1-c1[i],j2-c2[i]]+w[i]>f[j1-c1[i]*h[i],j2-c2[i]*h[i]]+w[i]*h[i] then
begin
if f[j1-c1[i],j2-c2[i]]+w[i]>f[j1,j2]
then f[j1,j2]:=f[j1-c1[i],j2-c2[i]]+w[i]
end
else
begin
if f[j1-c1[i]*h[i],j2-c2[i]*h[i]]+w[i]*h[i]>f[j1,j2]
then f[j1,j2]:=f[j1-c1[i]*h[i],j2-c2[i]*h[i]]+w[i]*h[i]
end;
end;
end;
writeln(f[cost1,cost2]);
close(input);
close(output)
end.