比赛 NOIP2008集训模拟4 评测结果 AAAAAAAAAA
题目名称 灵魂分流药剂 最终得分 100
用户昵称 thegy 运行时间 0.000 s
代码语言 Pascal 内存使用 0.00 MiB
提交时间 2008-11-13 09:23:21
显示代码纯文本
program soultap;
type
  node=record
         w,v,t,p:longint;
       end;
var
  fin,fout:text;
  o:array[1..100]of node;
  jl:array[1..10,0..100]of longint;
  f:array[0..100,0..100]of longint;
  n,m,a,b,p0,i,j,k,t1,t2,pp0:longint;
function hf(x:longint):boolean;
begin
  if x>=0 then hf:=true else hf:=false;
end;
procedure updata(var x:longint;y:longint);
begin
  if y>x then x:=y;
end;
begin
  assign(fin,'soultap.in'); reset(fin);
  assign(fout,'soultap.out'); rewrite(fout);
  read(fin,n,m,a,b);
  for i:=1 to m do jl[i,0]:=0;
  for i:=1 to n do begin
    read(fin,o[i].w,o[i].v,o[i].t,o[i].p);
    inc(jl[o[i].t,0]); p0:=jl[o[i].t,0];
    jl[o[i].t,p0]:=i;
  end;
  for i:=1 to a do f[i,0]:=0;
  for j:=1 to b do f[0,i]:=0;
  for k:=1 to m do
    for i:=a downto 1 do
      for j:=b downto 1 do
        for p0:=1 to jl[k,0] do begin
          pp0:=jl[k,p0];
          t1:=i-o[pp0].w;
          t2:=j-o[pp0].v;
          if( not(hf(t1)) )or( not(hf(t2)) )then continue;
          updata(f[i,j],f[t1,t2]+o[pp0].p);
        end;
  writeln(fout,f[a,b]);
  close(fin);
  close(fout);
end.