比赛 NOIP2008集训模拟4 评测结果 WEWWEEEETE
题目名称 灵魂分流药剂 最终得分 0
用户昵称 zpl123 运行时间 0.000 s
代码语言 Pascal 内存使用 0.00 MiB
提交时间 2008-11-13 11:26:48
显示代码纯文本
program soultap;
type
tt=array[0..6,0..100]of longint;
t2=array[0..6,0..100,0..100] of longint;
t3=array[0..6]of longint;
var
n,m,a,b:longint;
f:t2;
p,w,v:tt;
num:t3;

procedure init;
var
i,j,w1,v1,t1,p1:longint;
begin
assign(input,'soultap.in');
reset(input);
assign(output,'soultap.out');
rewrite(output);
readln(n,m,a,b);
for i:=1 to n do
 begin
 readln(w1,v1,t1,p1);
 inc(num[t1]);
 w[t1,num[t1]]:=w1;
 v[t1,num[t1]]:=v1;
 p[t1,num[t1]]:=p1;
 end;
close(input);
fillchar(f,sizeof(f),0);
end;


procedure main;
var
i,j,k,u,d,t,a1:longint;

begin
for k:=1 to m do
 for u:=a downto 0 do
  for d:=b downto 0 do
   begin
   a1:=1;
   for i:=1 to num[k] do
   begin
   t:=f[k,u,d];
   if (u-w[k,a1]>=0)and(d-v[k,a1]>=0) then begin
   if t<f[k,u-w[k,a1],d-v[k,a1]]+p[k,i] then
   begin
   t:=f[k,u-w[k,a1],d-v[k,a1]]+p[k,i];
   a1:=i;
   end;
   end;
   f[k,u,d]:=t;
   end;
end;
end;

procedure print;
var
ans,i,j,k:longint;
begin
ans:=0;
for i:=1 to 5 do
 for j:=0 to 100 do
  for k:=0 to 100 do
  if ans<=f[i,j,k] then ans:=f[i,j,k];
writeln(ans);
close(output);
end;

begin
init;
main;
print;
end.