提交记录 15862
提交时间 |
评测时间 |
2021-02-23 23:26:22 |
2023-09-03 19:41:35 |
#include <bits/extc++.h>
using namespace std;
#ifndef NDEBUG
#define debug(x) cout << "Line " << __LINE__ << " " << #x << " = " << (x) << endl;
#endif
#ifdef NDEBUG
#define debug(x)
#endif
#define rep(Begin, End) for (int Begin = 1; Begin <= End; Begin++)
int n, m, a[25], ans;
#include <x86intrin.h>
int table[] = {0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4};
inline int popcount(unsigned int val)
{
int cnt = 0;
while (val)
{
cnt += table[val & 15];
val >>= 4;
}
return cnt;
}
int main()
{
cin >> n >> m;
for (int i = 0; i < n; i++)
{
cin >> a[i];
}
for (int i = 1; i < (1 << n); i++)
{
if (__popcntq(i) == n - m)
{
bitset<2010> bs;
bs.set(0);
for (int j = 0; j < n; j++)
{
if (i & (1 << j))
{
bs |= bs << a[j];
}
}
ans = max(ans, (int)bs.count());
}
}
cout << ans - 1;
return 0;
}
Compilation | N/A | N/A | Compile OK | Score: N/A | 显示更多 |
Testcase #1 | 41.09 us | 36 KB | Accepted | Score: 100 | 显示更多 |
Judge Duck Online | 评测鸭在线
Server Time: 2024-04-24 13:21:15 | Loaded in 1 ms | Server Status
个人娱乐项目,仅供学习交流使用