比赛 |
NOIP2008集训模拟4 |
评测结果 |
AAAAAAAAAA |
题目名称 |
灵魂分流药剂 |
最终得分 |
100 |
用户昵称 |
王瑞祥K |
运行时间 |
0.000 s |
代码语言 |
Pascal |
内存使用 |
0.00 MiB |
提交时间 |
2008-11-13 11:06:50 |
显示代码纯文本
program soultap(input,output);
type
medc=record
w,v,p:longint;
end;
var
g:array[1..10]of integer;
med:array[1..10,1..100]of medc;
f:array[0..100,0..100]of longint;
m,n,a,b:integer;
procedure ini;
var i,rt,js,zu,valu:longint;
begin
assign(input,'soultap.in');assign(output,'soultap.out');
reset(input);rewrite(output);
readln(n,m,a,b);
for i:=1 to 10 do g[i]:=0;
for i:=1 to n do begin
readln(rt,js,zu,valu);
inc(g[zu]);
med[zu,g[zu]].w:=rt;
med[zu,g[zu]].v:=js;
med[zu,g[zu]].p:=valu;
end;
end;
procedure dp;
var i,k,j,l:integer;
begin
for k:=1 to m do
for j:=a downto 0 do
for l:=b downto 0 do
for i:=1 to g[k] do
if (j-med[k,i].w>=0)and(l-med[k,i].v>=0)then
if f[j-med[k,i].w,l-med[k,i].v]+med[k,i].p>f[j,l]
then f[j,l]:=f[j-med[k,i].w,l-med[k,i].v]+med[k,i].p;
write(f[a,b]);
close(input);close(output);
end;
begin
ini;
dp;
end.