比赛 |
NOIP2008集训模拟4 |
评测结果 |
AWAAWWWWWW |
题目名称 |
灵魂分流药剂 |
最终得分 |
30 |
用户昵称 |
elysian |
运行时间 |
0.000 s |
代码语言 |
Pascal |
内存使用 |
0.00 MiB |
提交时间 |
2008-11-13 10:07:49 |
显示代码纯文本
program soultap;
type
node=record
hp,mp:longint;
end;
const
fin='soultap.in';fout='soultap.out';
var
n,m,a,b,ans:longint;
f:array[0..11,0..110,0..110] of longint;
c:array[0..11,0..110] of node;
count:array[1..11] of longint;
p:array[0..11,0..110] of longint;
f1,f2:text;
function max(a,b:longint):longint;
begin
if a>=b then max:=a else max:=b;
end;
procedure init;
var
i,j,t1,t2,t3,t4:longint;
begin
fillchar(count,sizeof(count),0);
fillchar(f,sizeof(f),0);
fillchar(c,sizeof(c),0);
assign(f1,fin);reset(f1);
readln(f1,n,m,a,b);
for i:=1 to n do
begin
readln(f1,t1,t2,t3,t4);
inc(count[t3]);
c[t3,count[t3]].hp:=t1;
c[t3,count[t3]].mp:=t2;
p[t3,count[t3]]:=t4;
end;
close(f1);
end;
procedure main;
var
i,j,k,w,v,hp,mp:longint;
begin
for k:=1 to m do
for i:=1 to count[k] do
for w:=a downto 0 do
for v:=b downto 0 do
begin
hp:=c[k,i].hp;mp:=c[k,i].mp;
if (w-hp>=0)and(v-mp>=0) then
f[k,w,v]:=max(f[k-1,w,v],f[k-1,w-hp,v-mp]+p[k,i]);
if f[k,w,v]>ans then ans:=f[k,w,v]
end;
end;
begin
init;
main;
assign(f2,fout);rewrite(f2);
writeln(f2,ans);
close(f2);
end.