結果

問題 No.733 分身並列コーディング
ユーザー りあんりあん
提出日時 2017-08-26 20:01:50
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 43 ms / 1,500 ms
コード長 814 bytes
コンパイル時間 1,677 ms
コンパイル使用メモリ 168,704 KB
実行使用メモリ 13,824 KB
最終ジャッジ日時 2024-05-03 22:32:30
合計ジャッジ時間 3,818 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 41 ms
13,568 KB
testcase_04 AC 42 ms
13,568 KB
testcase_05 AC 43 ms
13,696 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 43 ms
13,696 KB
testcase_08 AC 43 ms
13,696 KB
testcase_09 AC 20 ms
8,448 KB
testcase_10 AC 4 ms
5,376 KB
testcase_11 AC 4 ms
5,376 KB
testcase_12 AC 2 ms
5,376 KB
testcase_13 AC 2 ms
5,376 KB
testcase_14 AC 10 ms
6,016 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 20 ms
8,448 KB
testcase_20 AC 19 ms
8,576 KB
testcase_21 AC 10 ms
6,016 KB
testcase_22 AC 42 ms
13,696 KB
testcase_23 AC 10 ms
6,016 KB
testcase_24 AC 10 ms
6,144 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 43 ms
13,568 KB
testcase_29 AC 42 ms
13,568 KB
testcase_30 AC 42 ms
13,568 KB
testcase_31 AC 43 ms
13,568 KB
testcase_32 AC 6 ms
5,376 KB
testcase_33 AC 6 ms
5,376 KB
testcase_34 AC 6 ms
5,376 KB
testcase_35 AC 6 ms
5,376 KB
testcase_36 AC 6 ms
5,376 KB
testcase_37 AC 6 ms
5,376 KB
testcase_38 AC 41 ms
13,568 KB
testcase_39 AC 43 ms
13,696 KB
testcase_40 AC 42 ms
13,696 KB
testcase_41 AC 6 ms
5,376 KB
testcase_42 AC 6 ms
5,376 KB
testcase_43 AC 6 ms
5,376 KB
testcase_44 AC 42 ms
13,696 KB
testcase_45 AC 42 ms
13,696 KB
testcase_46 AC 43 ms
13,568 KB
testcase_47 AC 42 ms
13,824 KB
testcase_48 AC 42 ms
13,568 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 T, n;
    cin >> T >> n;
    vector<int> t(n);
    for (int i = 0; i < n; ++i)
        cin >> t[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] + t[j]);
                    if (dp[i][k] <= T) dp[i][k + 1] = 0;
                }
            }
        }
    }
    for (int i = 0; i <= n; ++i) {
        if (!dp[(1 << n) - 1][i]) {
            cout << i << "\n";
            return 0;
        }
    }
}
0