# 暗黑破坏神

Time Limit:10000MS  Memory Limit:65536K
Total Submit:100 Accepted:35
Case Time Limit:1000MS

Description

Input

c[i] p[i] w[i][1] w[i][2] ... w[i][p[i]]

Output

Sample Input

3 10
1 3 1 2 2
2 3 2 4 6
3 3 2 1 10

Sample Output

11
1
0
3

Hint

0< n< =100,0< m <=500,0 < p[i] <= 50,0 < c[i] <=10

Source

• var
n,money:longint;
cost:array[1..100] of longint;
total:array[1..100] of longint;
value:array[1..100,0..50] of longint;
f:array[0..100,0..500] of longint;
d:array[0..100,0..500] of longint;
procedure init;
var
i,j:longint;
begin
for i:=1 to n do
begin
for j:=1 to total[i] do
end;
end;
procedure _output(dn,dmoney:longint);
begin
if dn=0 then exit;
_output(dn-1,dmoney-d[dn,dmoney]*cost[dn]);
writeln(d[dn,dmoney])
end;
procedure solve;
var
i,j,k,max,maxp:longint;
begin
fillchar(f,sizeof(f),0);
f[0,0]:=0;
for i:=1 to n do
for j:=0 to money do
for k:=0 to total[i] do
begin
if j<k*cost[i] then break;
if f[i-1,j-k*cost[i]]+value[i][k]>f[i,j] then
begin
f[i,j]:=f[i-1,j-k*cost[i]]+value[i][k];
d[i,j]:=k;
end;
end;
max:=-maxlongint;
for i:=0 to money do
if f[n,i]>max then
begin
max:=f[n,i];
maxp:=i;
end;
writeln(max);
_output(n,maxp);
end;
begin
init;
solve;
end.