結果

問題 No.733 分身並列コーディング
ユーザー MisterMister
提出日時 2020-08-07 15:31:21
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 187 ms / 1,500 ms
コード長 988 bytes
コンパイル時間 700 ms
コンパイル使用メモリ 77,476 KB
実行使用メモリ 12,996 KB
最終ジャッジ日時 2023-10-24 16:06:07
合計ジャッジ時間 6,213 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 112 ms
12,996 KB
testcase_04 AC 109 ms
12,996 KB
testcase_05 AC 182 ms
12,996 KB
testcase_06 AC 2 ms
4,348 KB
testcase_07 AC 187 ms
12,996 KB
testcase_08 AC 185 ms
12,996 KB
testcase_09 AC 68 ms
7,980 KB
testcase_10 AC 8 ms
4,348 KB
testcase_11 AC 8 ms
4,348 KB
testcase_12 AC 1 ms
4,348 KB
testcase_13 AC 2 ms
4,348 KB
testcase_14 AC 31 ms
5,604 KB
testcase_15 AC 4 ms
4,348 KB
testcase_16 AC 2 ms
4,348 KB
testcase_17 AC 2 ms
4,348 KB
testcase_18 AC 9 ms
4,348 KB
testcase_19 AC 67 ms
7,980 KB
testcase_20 AC 71 ms
7,980 KB
testcase_21 AC 30 ms
5,604 KB
testcase_22 AC 149 ms
12,996 KB
testcase_23 AC 33 ms
5,604 KB
testcase_24 AC 36 ms
5,604 KB
testcase_25 AC 2 ms
4,348 KB
testcase_26 AC 2 ms
4,348 KB
testcase_27 AC 5 ms
4,348 KB
testcase_28 AC 183 ms
12,996 KB
testcase_29 AC 169 ms
12,996 KB
testcase_30 AC 164 ms
12,996 KB
testcase_31 AC 162 ms
12,996 KB
testcase_32 AC 17 ms
4,348 KB
testcase_33 AC 18 ms
4,348 KB
testcase_34 AC 17 ms
4,348 KB
testcase_35 AC 17 ms
4,348 KB
testcase_36 AC 18 ms
4,348 KB
testcase_37 AC 17 ms
4,348 KB
testcase_38 AC 167 ms
12,996 KB
testcase_39 AC 171 ms
12,996 KB
testcase_40 AC 175 ms
12,996 KB
testcase_41 AC 17 ms
4,348 KB
testcase_42 AC 18 ms
4,348 KB
testcase_43 AC 17 ms
4,348 KB
testcase_44 AC 171 ms
12,996 KB
testcase_45 AC 172 ms
12,996 KB
testcase_46 AC 173 ms
12,996 KB
testcase_47 AC 172 ms
12,996 KB
testcase_48 AC 169 ms
12,996 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>

template <class T>
std::vector<T> vec(int len, T elem) { return std::vector<T>(len, elem); }

void solve() {
    int t, n;
    std::cin >> t >> n;

    std::vector<int> xs(n);
    for (auto& x : xs) std::cin >> x;

    auto dp = vec(n + 1, vec(1 << n, t + 1));
    dp[0][0] = 0;

    for (int k = 0; k < n; ++k) {
        for (int b = 0; b < (1 << n); ++b) {
            if (dp[k][b] > t) continue;

            // reset
            dp[k + 1][b] = 0;

            // solve
            for (int i = 0; i < n; ++i) {
                if ((b >> i) & 1) continue;

                int nb = b | (1 << i);
                dp[k][nb] = std::min(dp[k][nb], dp[k][b] + xs[i]);
            }
        }
    }

    for (int k = 0; k <= n; ++k) {
        if (dp[k].back() == 0) {
            std::cout << k << "\n";
            return;
        }
    }
}

int main() {
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);

    solve();

    return 0;
}
0