結果

問題 No.137 貯金箱の焦り
ユーザー maine_honzukimaine_honzuki
提出日時 2020-05-19 21:24:11
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 637 bytes
コンパイル時間 1,451 ms
コンパイル使用メモリ 165,608 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-04-09 22:27:17
合計ジャッジ時間 3,525 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
6,816 KB
testcase_01 AC 3 ms
6,944 KB
testcase_02 AC 12 ms
6,940 KB
testcase_03 AC 2 ms
6,940 KB
testcase_04 AC 14 ms
6,940 KB
testcase_05 AC 6 ms
6,940 KB
testcase_06 AC 14 ms
6,944 KB
testcase_07 AC 10 ms
6,940 KB
testcase_08 AC 10 ms
6,940 KB
testcase_09 AC 14 ms
6,944 KB
testcase_10 AC 9 ms
6,940 KB
testcase_11 AC 5 ms
6,944 KB
testcase_12 WA -
testcase_13 AC 18 ms
6,940 KB
testcase_14 AC 121 ms
6,940 KB
testcase_15 AC 105 ms
6,940 KB
testcase_16 AC 108 ms
6,940 KB
testcase_17 AC 64 ms
6,944 KB
testcase_18 AC 101 ms
6,940 KB
testcase_19 AC 120 ms
6,940 KB
testcase_20 AC 6 ms
6,940 KB
testcase_21 AC 79 ms
6,940 KB
testcase_22 AC 27 ms
6,944 KB
testcase_23 AC 23 ms
6,944 KB
testcase_24 AC 55 ms
6,944 KB
testcase_25 AC 100 ms
6,944 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll mod = 1234567891ll;

int main() {
    ll N, M;
    cin >> N >> M;
    vector<int> A(N);
    for (int i = 0; i < N; i++) {
        cin >> A[i];
    }

    vector<ll> dp(31000);
    dp[0] = 1;

    while (M) {
        for (int i = 0; i < N; i++) {
            for (int x = 30000; x >= 0; x--) {
                (dp[x + A[i]] += dp[x]) %= mod;
            }
        }
        for (int i = 0; i < 15000; i++) {
            dp[i] = dp[i * 2 + M % 2ll];
        }
        fill(dp.begin() + 15000, dp.end(), 0ll);
        M >>= 1;
    }

    cout << dp[0] << endl;
}
0