记录编号 8226 评测结果 AAAAAAAAAA
题目名称 [BYVoid S1] 灵魂分流药剂 最终得分 100
用户昵称 GravatarWaterFire 是否通过 通过
代码语言 Pascal 运行时间 0.125 s
提交时间 2008-11-13 12:14:57 内存使用 0.17 MiB
显示代码纯文本
program waterfire;
var
i,j,k,q,p,n,m,l,max:longint;
v:array[0..100,0..100] of longint;
a:array[1..10,1..100] of longint;
b:array[1..100,1..4] of longint;
c:array[1..10] of longint;
t:text;
f:array[0..100,0..100] of boolean;
begin
assign(t,'soultap.in');
reset(t);
fillchar(v,sizeof(v),0);
fillchar(a,sizeof(a),0);
fillchar(b,sizeof(b),0);
fillchar(c,sizeof(c),0);
readln(t,n,m,q,p);
for i:=1 to n do
 begin
  readln(t,b[i,1],b[i,2],b[i,3],b[i,4]);
  inc(c[b[i,3]]);
  a[b[i,3],c[b[i,3]]]:=i;
 end;
for i:=1 to 10 do
 begin
 fillchar(f,sizeof(f),false);
 for j:=1 to c[i] do
  for k:=q downto 0 do
   for l:=p downto 0 do
    if (k-b[a[i,j],1]>=0)and(l-b[a[i,j],2]>=0)and(f[k-b[a[i,j],1],l-b[a[i,j],2]]<>true) then
     if v[k,l]<v[k-b[a[i,j],1],l-b[a[i,j],2]]+b[a[i,j],4]
      then begin v[k,l]:=v[k-b[a[i,j],1],l-b[a[i,j],2]]+b[a[i,j],4];f[k,l]:=true;end;
 end;
max:=0;
for i:=1 to q do
 for j:=1 to p do
  if v[i,j]>max then max:=v[i,j];
assign(t,'soultap.out');
rewrite(t);
write(t,max);
close(t);
end.