結果

問題 No.733 分身並列コーディング
ユーザー りあんりあん
提出日時 2017-06-09 11:49:34
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
RE  
実行時間 -
コード長 1,014 bytes
コンパイル時間 1,776 ms
コンパイル使用メモリ 165,540 KB
実行使用メモリ 29,184 KB
最終ジャッジ日時 2024-04-23 17:17:02
合計ジャッジ時間 8,147 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
6,812 KB
testcase_01 AC 2 ms
6,812 KB
testcase_02 AC 2 ms
6,940 KB
testcase_03 RE -
testcase_04 RE -
testcase_05 RE -
testcase_06 AC 3 ms
6,944 KB
testcase_07 RE -
testcase_08 RE -
testcase_09 RE -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 RE -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 15 ms
19,004 KB
testcase_19 RE -
testcase_20 RE -
testcase_21 RE -
testcase_22 RE -
testcase_23 RE -
testcase_24 RE -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 RE -
testcase_29 RE -
testcase_30 RE -
testcase_31 RE -
testcase_32 AC 28 ms
29,088 KB
testcase_33 AC 42 ms
29,056 KB
testcase_34 AC 36 ms
29,184 KB
testcase_35 AC 26 ms
29,184 KB
testcase_36 AC 33 ms
29,184 KB
testcase_37 AC 24 ms
29,184 KB
testcase_38 RE -
testcase_39 RE -
testcase_40 RE -
testcase_41 AC 27 ms
29,024 KB
testcase_42 AC 31 ms
29,056 KB
testcase_43 AC 35 ms
29,184 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][200];
int mi[1 << 14][200];

int main()
{
    // O(N C 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 = 0; i < (1 << n); ++i) {
        for (int j = 0; j < c; ++j) {
            mi[i][j] = 10000;
            dp[i][j] = 10000;
        }
    }
    dp[0][0] = 0;
    for (int i = 0; i < c; ++i)
        mi[0][i] = 0;

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

    return 0;
}
0