提交记录 15862


用户 题目 状态 得分 用时 内存 语言 代码长度
phoenix1203 test. 自定义测试 Compile Error 0 0 ns 0 KB C++ 1.01 KB
提交时间 评测时间
2021-02-23 23:26:22 2021-02-23 23:26:24
#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;
}

CompilationN/AN/ACompile ErrorScore: N/A


Judge Duck Online | 评测鸭在线
Server Time: 2021-03-03 16:02:02 | Loaded in 0 ms | Server Status
个人娱乐项目,仅供学习交流使用