#include <bits/stdc++.h>
using namespace std;
int n, m, a[21], res;
int main() {
scanf("%d%d", &n, &m);
for(int i = 1; i <= n; i++) scanf("%d", &a[i]);
int b = (1 << (n - m)) - 1;
while (b < 1 << n) {
bitset<2010> f;
f[0] = 1;
for(int i = 1; i <= n; i++)if(b & 1 << (i - 1)) f |= f << a[i];
res = max(res, int(f.count()));
int x = b & -b, y = b + x;
b = ((b & ~y) / x >> 1) | y;
}
printf("%d\n", res - 1);
}
P1441 砝码称重
最新推荐文章于 2023-12-16 09:41:34 发布