记录编号 14282 评测结果 AAAAAAAAAA
题目名称 [BYVoid S1] 灵魂分流药剂 最终得分 100
用户昵称 Gravatar打不死的羊 是否通过 通过
代码语言 Pascal 运行时间 0.012 s
提交时间 2009-10-28 15:52:20 内存使用 0.24 MiB
显示代码纯文本
program soultap;
type
fxz1=record aa,bb,tt:longint; end;
fxz2=array[1..100] of fxz1;
fxz3=array[1..10] of fxz2;
fxz4=array[0..100,0..100] of longint;
fxz5=array[0..100] of longint;
fxz6=array[0..100,0..100] of boolean;
var
f1,f2:text;
box:fxz3;
ans:fxz4;
flag,fls:fxz6;
l:fxz5;
i,j,a,n,m,b,p,max,k,x,y,za,zb,t:longint;


begin assign(f1,'soultap.in');
      assign(f2,'soultap.out');
      reset(f1);rewrite(f2);
      readln(f1,n,m,a,b);
      for i:=0 to a do
      for j:=0 to b do begin ans[i,j]:=0;
                             flag[i,j]:=false;
                        end;
      for i:=1 to m do l[0]:=0;
      for i:=1 to n do
      begin readln(f1,za,zb,t,p);
            inc(l[t]);
            box[t][l[t]].aa:=za;
            box[t][l[t]].bb:=zb;
            box[t][l[t]].tt:=p;
      end;
      flag[0,0]:=true;
      {......................................................}
      for i:=1 to m do
       begin   fls:=flag;
               for x:=a downto 0 do
               for y:=b downto 0 do
               if (l[i]<>0)and(flag[x,y]) then
                  for j:=1 to l[i] do
                  if (x+box[i][j].aa<=a)and(y+box[i][j].bb<=b) then
                  if ans[x,y]+box[i][j].tt>=ans[x+box[i][j].aa,y+box[i][j].bb] then
                   begin ans[x+box[i][j].aa,y+box[i][j].bb]:=ans[x,y]+box[i][j].tt;
                         fls[x+box[i][j].aa,y+box[i][j].bb]:=true;
                    end;
               flag:=fls;
       end;
      max:=0;
      for i:=0 to a do
      for j:=0 to b do if ans[i,j]>max then max:=ans[i,j];
      writeln(f2,max);
      close(f1);close(f2);
end.