记录编号 |
8321 |
评测结果 |
AAAAAAAAAA |
题目名称 |
[BYVoid S1] 灵魂分流药剂 |
最终得分 |
100 |
用户昵称 |
elysian |
是否通过 |
通过 |
代码语言 |
Pascal |
运行时间 |
0.150 s |
提交时间 |
2008-11-13 16:35:09 |
内存使用 |
0.17 MiB |
显示代码纯文本
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..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 w:=a downto 0 do
for v:=b downto 0 do
for i:=1 to count[k] do
begin
hp:=c[k,i].hp;mp:=c[k,i].mp;
if (w-hp>=0)and(v-mp>=0) then
f[w,v]:=max(f[w,v],f[w-hp,v-mp]+p[k,i]);
if f[w,v]>ans then ans:=f[w,v]
end;
end;
begin
init;
main;
assign(f2,fout);rewrite(f2);
writeln(f2,ans);
close(f2);
end.