結果

問題 No.733 分身並列コーディング
ユーザー merom686merom686
提出日時 2018-09-10 17:35:23
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 69 ms / 1,500 ms
コード長 1,104 bytes
コンパイル時間 667 ms
コンパイル使用メモリ 78,596 KB
実行使用メモリ 16,476 KB
最終ジャッジ日時 2023-08-28 19:13:09
合計ジャッジ時間 3,266 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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 68 ms
16,476 KB
testcase_04 AC 69 ms
16,280 KB
testcase_05 AC 25 ms
16,432 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 29 ms
16,336 KB
testcase_08 AC 27 ms
16,212 KB
testcase_09 AC 27 ms
9,720 KB
testcase_10 AC 4 ms
4,376 KB
testcase_11 AC 4 ms
4,380 KB
testcase_12 AC 2 ms
4,380 KB
testcase_13 AC 1 ms
4,376 KB
testcase_14 AC 14 ms
6,436 KB
testcase_15 AC 2 ms
4,376 KB
testcase_16 AC 1 ms
4,380 KB
testcase_17 AC 1 ms
4,380 KB
testcase_18 AC 3 ms
4,376 KB
testcase_19 AC 28 ms
9,600 KB
testcase_20 AC 24 ms
9,608 KB
testcase_21 AC 14 ms
6,436 KB
testcase_22 AC 52 ms
16,436 KB
testcase_23 AC 13 ms
6,396 KB
testcase_24 AC 11 ms
6,684 KB
testcase_25 AC 1 ms
4,380 KB
testcase_26 AC 1 ms
4,380 KB
testcase_27 AC 2 ms
4,376 KB
testcase_28 AC 31 ms
16,200 KB
testcase_29 AC 43 ms
16,328 KB
testcase_30 AC 42 ms
16,200 KB
testcase_31 AC 42 ms
16,404 KB
testcase_32 AC 6 ms
4,620 KB
testcase_33 AC 6 ms
4,708 KB
testcase_34 AC 6 ms
4,708 KB
testcase_35 AC 5 ms
4,836 KB
testcase_36 AC 6 ms
4,668 KB
testcase_37 AC 6 ms
4,548 KB
testcase_38 AC 39 ms
16,184 KB
testcase_39 AC 37 ms
16,384 KB
testcase_40 AC 37 ms
16,376 KB
testcase_41 AC 6 ms
4,552 KB
testcase_42 AC 6 ms
4,596 KB
testcase_43 AC 6 ms
4,596 KB
testcase_44 AC 38 ms
16,360 KB
testcase_45 AC 37 ms
16,348 KB
testcase_46 AC 38 ms
16,328 KB
testcase_47 AC 37 ms
16,376 KB
testcase_48 AC 38 ms
16,308 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

int main() {
    int T, n;
    cin >> T >> n;

    vector<int> t(n);
    for (int i = 0; i < n; i++) {
        cin >> t[i];
    }

    vector<vector<int>> dp(1 << n, vector<int>(n + 1));
    for (int k = 0; k < 1 << n; k++) {

        int x = 0;
        for (int i = 0; i < n; i++) {
            if (k & 1 << i) {
                x += t[i];
            }
        }
        dp[k][0] = x;

        for (int j = 1; j <= n; j++) {
            if (dp[k][j - 1] <= T) {
                dp[k][j] = 0;
                continue;
            }
            int x = 1 << 30;
            for (int i = 0; i < n; i++) {
                if (k & 1 << i) {
                    x = min(x, dp[k ^ 1 << i][j] + t[i]);
                }
            }
            dp[k][j] = x;
        }
    }

    for (int j = 0; j <= n; j++) {
        if (dp[(1 << n) - 1][j] == 0) {
            cout << j << endl;
            break;
        }
    }

    return 0;
}
0