比赛 NOIP2008集训模拟4 评测结果 AAAAATAAAA
题目名称 灵魂分流药剂 最终得分 90
用户昵称 chengyang 运行时间 0.000 s
代码语言 Pascal 内存使用 0.00 MiB
提交时间 2008-11-13 11:04:37
显示代码纯文本
program soultap;
var
  a1,b1,m,n,max,k:longint;
  mm:array[1..11]of boolean;
  nn:array[1..101,1..5]of longint;
procedure ini;
var
  i:longint;
begin
  assign(input,'soultap.in');
  assign(output,'soultap.out');
  reset(input); rewrite(output);
  readln(n,m,a1,b1);
  for i:=1 to n do  readln(nn[i,1],nn[i,2],nn[i,3],nn[i,4]);
  for i:=1 to 10 do mm[i]:=true;
  max:=0;
End;
procedure go(k,a2,b2,c:longint);
var
  i,j:longint;
Begin
   mm[nn[k,3]]:=false;
   for i:=1 to n do begin
     if (mm[nn[i,3]]) and (a2+nn[i,1]<=a1) and(b2+nn[i,2]<=b1) then begin
       if c+nn[i,4]>max then max:=c+nn[i,4];
       go(i,a2+nn[i,1],b2+nn[i,2],c+nn[i,4]);
     end;
   end;
   mm[nn[k,3]]:=true;
End;
Begin
  ini;
  for k:=1 to n do begin
    go(k,nn[k,1],nn[k,2],nn[k,4]);
  end;
  writeln(max);
  close(input); close(output);
End.