結果

問題 No.137 貯金箱の焦り
ユーザー maine_honzukimaine_honzuki
提出日時 2020-05-19 21:25:40
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 246 ms / 5,000 ms
コード長 637 bytes
コンパイル時間 1,308 ms
コンパイル使用メモリ 166,620 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-04-09 22:27:26
合計ジャッジ時間 4,304 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 4 ms
6,812 KB
testcase_01 AC 4 ms
6,944 KB
testcase_02 AC 22 ms
6,948 KB
testcase_03 AC 2 ms
6,940 KB
testcase_04 AC 27 ms
6,940 KB
testcase_05 AC 11 ms
6,940 KB
testcase_06 AC 25 ms
6,940 KB
testcase_07 AC 17 ms
6,944 KB
testcase_08 AC 19 ms
6,940 KB
testcase_09 AC 27 ms
6,940 KB
testcase_10 AC 16 ms
6,940 KB
testcase_11 AC 8 ms
6,940 KB
testcase_12 AC 246 ms
6,940 KB
testcase_13 AC 36 ms
6,944 KB
testcase_14 AC 241 ms
6,940 KB
testcase_15 AC 211 ms
6,940 KB
testcase_16 AC 216 ms
6,944 KB
testcase_17 AC 127 ms
6,944 KB
testcase_18 AC 203 ms
6,944 KB
testcase_19 AC 240 ms
6,940 KB
testcase_20 AC 12 ms
6,944 KB
testcase_21 AC 158 ms
6,940 KB
testcase_22 AC 51 ms
6,944 KB
testcase_23 AC 45 ms
6,944 KB
testcase_24 AC 109 ms
6,940 KB
testcase_25 AC 185 ms
6,940 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(61000);
    dp[0] = 1;

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

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