結果

問題 No.733 分身並列コーディング
ユーザー りあんりあん
提出日時 2017-08-25 05:58:08
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 45 ms / 1,500 ms
コード長 862 bytes
コンパイル時間 1,479 ms
コンパイル使用メモリ 165,984 KB
実行使用メモリ 15,940 KB
最終ジャッジ日時 2023-08-16 14:11:48
合計ジャッジ時間 5,050 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 44 ms
15,632 KB
testcase_04 AC 43 ms
15,688 KB
testcase_05 AC 45 ms
15,672 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 42 ms
15,628 KB
testcase_08 AC 44 ms
15,628 KB
testcase_09 AC 21 ms
9,696 KB
testcase_10 AC 4 ms
4,380 KB
testcase_11 AC 4 ms
4,376 KB
testcase_12 AC 2 ms
4,376 KB
testcase_13 AC 2 ms
4,376 KB
testcase_14 AC 11 ms
7,560 KB
testcase_15 AC 2 ms
4,380 KB
testcase_16 AC 1 ms
4,376 KB
testcase_17 AC 2 ms
4,376 KB
testcase_18 AC 3 ms
4,376 KB
testcase_19 AC 20 ms
9,524 KB
testcase_20 AC 21 ms
9,484 KB
testcase_21 AC 11 ms
7,480 KB
testcase_22 AC 43 ms
15,620 KB
testcase_23 AC 11 ms
7,624 KB
testcase_24 AC 11 ms
7,628 KB
testcase_25 AC 1 ms
4,380 KB
testcase_26 AC 1 ms
4,384 KB
testcase_27 AC 3 ms
4,376 KB
testcase_28 AC 42 ms
15,620 KB
testcase_29 AC 43 ms
15,940 KB
testcase_30 AC 42 ms
15,628 KB
testcase_31 AC 43 ms
15,748 KB
testcase_32 AC 6 ms
4,636 KB
testcase_33 AC 5 ms
4,684 KB
testcase_34 AC 6 ms
4,680 KB
testcase_35 AC 6 ms
4,700 KB
testcase_36 AC 5 ms
4,620 KB
testcase_37 AC 6 ms
4,636 KB
testcase_38 AC 44 ms
15,668 KB
testcase_39 AC 43 ms
15,724 KB
testcase_40 AC 42 ms
15,708 KB
testcase_41 AC 6 ms
4,616 KB
testcase_42 AC 6 ms
4,844 KB
testcase_43 AC 6 ms
4,708 KB
testcase_44 AC 43 ms
15,832 KB
testcase_45 AC 43 ms
15,628 KB
testcase_46 AC 43 ms
15,640 KB
testcase_47 AC 42 ms
15,616 KB
testcase_48 AC 42 ms
15,632 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;

int dp[1 << 18][20];
const int M = 1000000007;

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] = M;

    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