好像题目有点问题?且现在决定不吃的宝物以后也不能再吃
好像下次还是可以吃的,就是这样
然后明显是状压dp,注意这道题明显倒推更容易
因为顺推很可能从一个无效状态推到有效状态
var f:array[..,..] of double;
v,a:array[..] of longint;
i,j,n,m,p,x,k:longint; function max(a,b:double):double;
begin
if a>b then exit(a) else exit(b);
end; begin
readln(n,k);
m:= shl k-;
for i:= to k do
begin
read(v[i]);
read(x);
while x<> do
begin
a[i]:=a[i]+ shl (x-);
read(x);
end;
end;
for i:=n downto do
begin
for j:= to m do
begin
for p:= to k do
if (a[p] and j)=a[p] then
f[i,j]:=f[i,j]+max(f[i+,j],f[i+,j or ( shl (p-))]+v[p])
else f[i,j]:=f[i,j]+f[i+,j];
f[i,j]:=f[i,j]/k;
end;
end;
writeln(f[,]::);
end.