比赛 NOIP2008集训模拟4 评测结果 WWWWWWWWWW
题目名称 灵魂分流药剂 最终得分 0
用户昵称 bing 运行时间 0.000 s
代码语言 Pascal 内存使用 0.00 MiB
提交时间 2008-11-13 11:22:19
显示代码纯文本
program bing;
type
 meifa=record
 w,v,p:integer;
end;
var
 f1,f2:text;
 n,m,a,b:integer;
 w,v,t,p:integer;
 max:integer;
 am:array[1..10] of integer;
 zh:array[1..10,1..10] of meifa;
 c:array[1..10] of integer;
 f:array[0..100,0..100] of integer;
 ff:array[0..100,0..100,1..10] of integer;  it,jt:integer;
procedure init;
var
 i,j:integer;
begin
 assign(f1,'soultap.in');reset(f1);
 assign(f2,'soultap.out');rewrite(f2);
 readln(f1,n,m,a,b);
 fillchar(am,sizeof(am),0);
 fillchar(f,sizeof(f),0);
 fillchar(ff,sizeof(ff),0);
 for i:=1 to n do
 begin
  readln(f1,w,v,t,p);
  inc(am[t]);
  zh[t,am[t]].w:=w;
  zh[t,am[t]].v:=v;
  zh[t,am[t]].p:=p;
 end;
end;
procedure nb;
var
 i,j,k,l:integer;
begin
 for i:=1 to a do
 for j:=1 to b do
 begin
  for k:=1 to m do
  begin
  if ff[i,j,k]=0 then
  begin
   for l:=1 to am[k] do
   if (i-zh[k,l].w>=0)and(j-zh[k,l].v>=0) then
    begin
     if f[i-zh[k,l].w,j-zh[k,l].v]+zh[k,l].p>f[i,j]
     then f[i,j]:=f[i-zh[k,l].w,j-zh[k,l].v]+zh[k,l].p;
     ff[i,j,k]:=1;
    end
   else f[i,j]:=0;
  end;
  end;

  if f[i,j]>max then begin max:=f[i,j]; it:=i;jt:=t;end;


 end;
end;
begin
 init;
 nb;
 write(f2,max);
 close(f1);close(f2);
end.