結果

問題 No.733 分身並列コーディング
ユーザー kyunakyuna
提出日時 2020-03-07 01:26:49
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 69 ms / 1,500 ms
コード長 844 bytes
コンパイル時間 765 ms
コンパイル使用メモリ 76,368 KB
実行使用メモリ 16,640 KB
最終ジャッジ日時 2024-04-22 11:40:55
合計ジャッジ時間 3,078 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 1 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 69 ms
16,512 KB
testcase_04 AC 69 ms
16,512 KB
testcase_05 AC 27 ms
16,640 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 34 ms
16,384 KB
testcase_08 AC 32 ms
16,512 KB
testcase_09 AC 33 ms
9,984 KB
testcase_10 AC 4 ms
5,376 KB
testcase_11 AC 5 ms
5,376 KB
testcase_12 AC 1 ms
5,376 KB
testcase_13 AC 2 ms
5,376 KB
testcase_14 AC 16 ms
6,528 KB
testcase_15 AC 3 ms
5,376 KB
testcase_16 AC 2 ms
5,376 KB
testcase_17 AC 2 ms
5,376 KB
testcase_18 AC 4 ms
5,376 KB
testcase_19 AC 33 ms
9,984 KB
testcase_20 AC 29 ms
9,984 KB
testcase_21 AC 18 ms
6,656 KB
testcase_22 AC 64 ms
16,640 KB
testcase_23 AC 16 ms
6,656 KB
testcase_24 AC 13 ms
6,656 KB
testcase_25 AC 2 ms
5,376 KB
testcase_26 AC 2 ms
5,376 KB
testcase_27 AC 3 ms
5,376 KB
testcase_28 AC 34 ms
16,512 KB
testcase_29 AC 51 ms
16,512 KB
testcase_30 AC 50 ms
16,512 KB
testcase_31 AC 50 ms
16,512 KB
testcase_32 AC 7 ms
5,376 KB
testcase_33 AC 7 ms
5,376 KB
testcase_34 AC 6 ms
5,376 KB
testcase_35 AC 7 ms
5,376 KB
testcase_36 AC 7 ms
5,376 KB
testcase_37 AC 6 ms
5,376 KB
testcase_38 AC 45 ms
16,384 KB
testcase_39 AC 46 ms
16,480 KB
testcase_40 AC 45 ms
16,640 KB
testcase_41 AC 7 ms
5,376 KB
testcase_42 AC 6 ms
5,376 KB
testcase_43 AC 6 ms
5,376 KB
testcase_44 AC 46 ms
16,512 KB
testcase_45 AC 45 ms
16,512 KB
testcase_46 AC 46 ms
16,640 KB
testcase_47 AC 46 ms
16,640 KB
testcase_48 AC 46 ms
16,384 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
const int INF = (int)1e9 + 7;
template<class t> inline bool chmin(t& a, t b) { if (a > b) { a = b; return 1; } return 0; }

int main() {
    int T, n; cin >> T >> n;
    vector<int> t(n);
    for (auto &ti: t) cin >> ti;
    vector<vector<int>> dp(1 << n, vector<int>(n + 1, INF));
    dp[0].assign(n + 1, 0);
    for (int mask = 0; mask < 1 << n; mask++) {
        for (int k = 0; k <= n; k++) {
            if (k && dp[mask][k - 1] <= T) {
                dp[mask][k] = 0;
                continue;
            }
            for (int i = 0; i < n; i++) if (mask >> i & 1) {
                chmin(dp[mask][k], dp[mask ^ (1 << i)][k] + t[i]);
            }
        }
    }
    int k = 0;
    while (dp[(1 << n) - 1][k]) k++;
    cout << k << endl;
    return 0;
}
0