結果

問題 No.733 分身並列コーディング
ユーザー アシツノカラアシツノカラ
提出日時 2023-12-14 21:34:03
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 179 ms / 1,500 ms
コード長 3,790 bytes
コンパイル時間 2,368 ms
コンパイル使用メモリ 209,488 KB
実行使用メモリ 22,784 KB
最終ジャッジ日時 2023-12-14 21:34:11
合計ジャッジ時間 8,042 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,676 KB
testcase_01 AC 2 ms
6,676 KB
testcase_02 AC 2 ms
6,676 KB
testcase_03 AC 171 ms
22,784 KB
testcase_04 AC 171 ms
22,784 KB
testcase_05 AC 177 ms
22,784 KB
testcase_06 AC 2 ms
6,676 KB
testcase_07 AC 175 ms
22,784 KB
testcase_08 AC 176 ms
22,784 KB
testcase_09 AC 81 ms
12,544 KB
testcase_10 AC 9 ms
6,676 KB
testcase_11 AC 9 ms
6,676 KB
testcase_12 AC 2 ms
6,676 KB
testcase_13 AC 2 ms
6,676 KB
testcase_14 AC 38 ms
7,680 KB
testcase_15 AC 5 ms
6,676 KB
testcase_16 AC 2 ms
6,676 KB
testcase_17 AC 2 ms
6,676 KB
testcase_18 AC 10 ms
6,676 KB
testcase_19 AC 81 ms
12,544 KB
testcase_20 AC 83 ms
12,544 KB
testcase_21 AC 39 ms
7,680 KB
testcase_22 AC 178 ms
22,784 KB
testcase_23 AC 38 ms
7,680 KB
testcase_24 AC 38 ms
7,680 KB
testcase_25 AC 2 ms
6,676 KB
testcase_26 AC 2 ms
6,676 KB
testcase_27 AC 5 ms
6,676 KB
testcase_28 AC 177 ms
22,784 KB
testcase_29 AC 178 ms
22,784 KB
testcase_30 AC 177 ms
22,784 KB
testcase_31 AC 177 ms
22,784 KB
testcase_32 AC 18 ms
6,676 KB
testcase_33 AC 17 ms
6,676 KB
testcase_34 AC 18 ms
6,676 KB
testcase_35 AC 18 ms
6,676 KB
testcase_36 AC 18 ms
6,676 KB
testcase_37 AC 19 ms
6,676 KB
testcase_38 AC 177 ms
22,784 KB
testcase_39 AC 177 ms
22,784 KB
testcase_40 AC 179 ms
22,784 KB
testcase_41 AC 18 ms
6,676 KB
testcase_42 AC 18 ms
6,676 KB
testcase_43 AC 18 ms
6,676 KB
testcase_44 AC 176 ms
22,784 KB
testcase_45 AC 178 ms
22,784 KB
testcase_46 AC 177 ms
22,784 KB
testcase_47 AC 179 ms
22,784 KB
testcase_48 AC 178 ms
22,784 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

// #if __has_include(<atcoder/all>)
//     #include <atcoder/all>
//     using namespace atcoder;
//     // using mint = modint;
//     // using mint = modint998244353;
//     // using mint = modint1000000007;
// #endif

#if __has_include(<my_debug_print.hpp>)
    #include <my_debug_print.hpp>
    #define debug(...) print_normal_for_debug(#__VA_ARGS__, __VA_ARGS__)
    #define debug_debug(...) print_format_for_debug(#__VA_ARGS__, __VA_ARGS__)
    #define debug_println(...) debug_println(__VA_ARGS__)
    #define debug_print(...) debug_print(__VA_ARGS__)
#else
    #define debug(...) (static_cast<void>(0))
    #define debug_debug(...) (static_cast<void>(0))
    #define debug_println(...) (static_cast<void>(0))
    #define debug_print(...) (static_cast<void>(0))
#endif

using namespace std;
using ll = long long;
using ld = long double;

constexpr char nl = '\n';
constexpr long long INF64 = 9223372036854775807;
constexpr long long INF = 200'0000'0000'0000'0000;
constexpr long double EPS = (long double)1e-13;

#define rep(i, a, n) for(long long i = (long long)(a); i < (long long)(n); ++i)
#define rrep(i, n, a) for(long long i = (long long)(n) - 1; (long long)(a) <= i; --i)
#define all(a) std::begin(a), std::end(a)
#define rall(a) std::rbegin(a), std::rend(a)
#define Sort(a) sort(std::begin(a), std::end(a))
#define rsort(a) sort(std::rbegin(a), std::rend(a))
#define fi first
#define se second


template <typename T>
void my_print(const T &arg) {
    std::cout << arg;
}

template <typename T, typename... U>
void my_print(const T &arg, const U&... args) {
    std::cout << arg;
    my_print(args...);
}

long long solve1(
    const long long& m,
    const long long& n,
    const vector<long long>& A
) {
    debug(n, m);
    debug(A);
    long long T = m;
    long long N = n;
    vector<long long> t = A;
    vector<vector<long long>> dp;
    dp.assign(N + 1, vector<long long>((1 << N) + 1, INF));
    dp[0][0] = 0;
    for (long long k = 0; k < N; ++k) {
        for (long long bit = 0; bit < (1 << N); ++bit) {
            if (dp[k][bit] <= T) dp[k + 1][bit] = 0;
            for (long long i = 0; i < N; ++i) {
                if (bit & (1 << i)) continue;
                long long nbit = bit | (1 << i);
                dp[k][nbit] = min(dp[k][nbit], dp[k][bit] + t[i]);
                if (dp[k][nbit] + t[i] <= T) dp[k+1][nbit] = 0;
            }
        }
    }
    long long res = N;
    for (long long k = 0; k < N; ++k) {
        if (dp[k][(1 << N) - 1] == 0) {
            res = min(res, k);
        }
    }
    debug(res);
    my_print(res, nl);
    return res;
}

long long solve2(
    const long long& T,
    const long long& N,
    const vector<long long>& A
) {
    debug(N, T);
    debug(A);
    return 0LL;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    std::cout << std::fixed << std::setprecision(15);

    {
        long long times = 1LL;
        {
            const char *file = "./_input.txt";
            FILE *fp;
            fp = fopen(file, "r");
            if (fp != NULL) {
                times = 3LL;  // サンプルの数に合わして繰り返す回数を決めることにする。
                fclose(fp);
            }
        }
        for (long long _index = 1LL; _index <= times; ++_index) {
            debug_println("--------------------------------", _index, "---------------------------------", '\n');
            long long T, N;
            cin >> T >> N;
            vector<long long> A(N, 0LL);
            rep (i1, 0, N) {
                cin >> A[i1];
            }
            solve1(T, N, A);
            // solve2(T, N, A);
            debug_println("------------------------------------------------------------------", '\n');
        }
    }
    return 0;
}
0