結果

問題 No.733 分身並列コーディング
ユーザー りあんりあん
提出日時 2018-09-07 07:03:53
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 72 ms / 1,500 ms
コード長 826 bytes
コンパイル時間 2,616 ms
コンパイル使用メモリ 202,444 KB
実行使用メモリ 16,584 KB
最終ジャッジ日時 2023-08-16 14:13:39
合計ジャッジ時間 5,032 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 72 ms
16,292 KB
testcase_04 AC 72 ms
16,232 KB
testcase_05 AC 30 ms
16,540 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 36 ms
16,440 KB
testcase_08 AC 35 ms
16,260 KB
testcase_09 AC 30 ms
9,596 KB
testcase_10 AC 4 ms
4,380 KB
testcase_11 AC 4 ms
4,376 KB
testcase_12 AC 1 ms
4,376 KB
testcase_13 AC 1 ms
4,380 KB
testcase_14 AC 15 ms
6,528 KB
testcase_15 AC 3 ms
4,380 KB
testcase_16 AC 1 ms
4,380 KB
testcase_17 AC 2 ms
4,380 KB
testcase_18 AC 4 ms
4,380 KB
testcase_19 AC 30 ms
9,604 KB
testcase_20 AC 27 ms
9,744 KB
testcase_21 AC 16 ms
6,428 KB
testcase_22 AC 58 ms
16,568 KB
testcase_23 AC 14 ms
6,488 KB
testcase_24 AC 12 ms
6,472 KB
testcase_25 AC 1 ms
4,380 KB
testcase_26 AC 1 ms
4,380 KB
testcase_27 AC 3 ms
4,376 KB
testcase_28 AC 35 ms
16,584 KB
testcase_29 AC 48 ms
16,284 KB
testcase_30 AC 48 ms
16,432 KB
testcase_31 AC 49 ms
16,260 KB
testcase_32 AC 7 ms
4,628 KB
testcase_33 AC 6 ms
4,680 KB
testcase_34 AC 6 ms
4,932 KB
testcase_35 AC 7 ms
4,736 KB
testcase_36 AC 6 ms
4,632 KB
testcase_37 AC 7 ms
4,684 KB
testcase_38 AC 45 ms
16,540 KB
testcase_39 AC 45 ms
16,556 KB
testcase_40 AC 45 ms
16,512 KB
testcase_41 AC 6 ms
4,680 KB
testcase_42 AC 7 ms
4,852 KB
testcase_43 AC 6 ms
4,684 KB
testcase_44 AC 45 ms
16,184 KB
testcase_45 AC 44 ms
16,492 KB
testcase_46 AC 45 ms
16,520 KB
testcase_47 AC 45 ms
16,184 KB
testcase_48 AC 44 ms
16,260 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
const int M = 1000000007;

int main() {
    // O(n^2 2^n)
    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, M));
    for (int i = 0; i < n + 1; ++i) dp[0][i] = 0;

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