\(f[i][j]\) 表示第1到i-1轮宝物是否取过的状态是j,第i轮到最后一轮的最大得分。
这样设计状态并且倒着推,可以保证不合法的状态是0,不会造成影响
\(nd[i]\)表示第i个物品要求的状态
#includeusing namespace std;typedef long long LL;#define lop(i,a,b) for(register int i = (a); i <= (b); ++i)#define dlop(i,a,b) for(register int i = (a); i >= (b); --i)#define eps (1e-7)inline int read(){ register int c = getchar(), x = 0, f = 1; while(!isdigit(c)) {if (c == '-') f = -1; c = getchar();} while(isdigit(c)) x = (x<<3)+(x<<1)+(c^48), c = getchar(); return x * f;}double f[105][65536]; int a[16], w[16], s[16], n, m, k, nd[16];int main(void){ scanf("%d%d", &n, &m); for(int i = 1; i <= m; ++i) { int tmp; scanf("%d%d", &w[i], &tmp); while(tmp) nd[i] |= (1< = f[i+1][j|(1<