結果

問題 No.733 分身並列コーディング
ユーザー りあんりあん
提出日時 2017-06-09 14:38:42
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
RE  
実行時間 -
コード長 841 bytes
コンパイル時間 1,546 ms
コンパイル使用メモリ 164,724 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-04-23 17:17:15
合計ジャッジ時間 5,908 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,812 KB
testcase_01 AC 2 ms
6,944 KB
testcase_02 AC 2 ms
6,944 KB
testcase_03 RE -
testcase_04 RE -
testcase_05 RE -
testcase_06 AC 2 ms
6,940 KB
testcase_07 RE -
testcase_08 RE -
testcase_09 RE -
testcase_10 AC 4 ms
6,944 KB
testcase_11 AC 4 ms
6,940 KB
testcase_12 AC 2 ms
6,940 KB
testcase_13 AC 2 ms
6,940 KB
testcase_14 RE -
testcase_15 AC 3 ms
6,940 KB
testcase_16 AC 2 ms
6,940 KB
testcase_17 AC 2 ms
6,940 KB
testcase_18 AC 4 ms
6,944 KB
testcase_19 RE -
testcase_20 RE -
testcase_21 RE -
testcase_22 RE -
testcase_23 RE -
testcase_24 RE -
testcase_25 AC 2 ms
6,940 KB
testcase_26 AC 1 ms
6,944 KB
testcase_27 AC 2 ms
6,948 KB
testcase_28 RE -
testcase_29 RE -
testcase_30 RE -
testcase_31 RE -
testcase_32 AC 6 ms
6,940 KB
testcase_33 AC 6 ms
6,944 KB
testcase_34 AC 6 ms
6,940 KB
testcase_35 AC 6 ms
6,944 KB
testcase_36 AC 6 ms
6,940 KB
testcase_37 AC 6 ms
6,944 KB
testcase_38 RE -
testcase_39 RE -
testcase_40 RE -
testcase_41 AC 7 ms
6,944 KB
testcase_42 AC 6 ms
6,944 KB
testcase_43 AC 6 ms
6,944 KB
testcase_44 RE -
testcase_45 RE -
testcase_46 RE -
testcase_47 RE -
testcase_48 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>

using namespace std;

int dp[1 << 14][16];

int main()
{
    // O(N^2 2^N)
    int c, n;
    cin >> c >> n;
    vector<int> w(n);
    for (int i = 0; i < n; ++i) {
        cin >> w[i];
    }
    for (int i = 1; i < (1 << n); ++i)
        for (int j = 0; j <= n; ++j)
            dp[i][j] = 10000;

    for (int i = 1; i < (1 << n); ++i) {
        for (int j = 0; j < n; ++j) {
            if ((i >> j) & 1) {
                for (int k = 0; k <= n; ++k) {
                    dp[i][k] = min(dp[i][k], dp[i ^ (1 << j)][k] + w[j]);
                    if (dp[i][k] <= c)
                        dp[i][k + 1] = 0;
                }
            }
        }
    }
    for (int i = 0; i <= n; ++i) {
        if (!dp[(1 << n) - 1][i]) {
            cout << i << "\n";
            return 0;
        }
    }

    return 0;
}
0