結果

問題 No.269 見栄っ張りの募金活動
ユーザー At-sushiAt-sushi
提出日時 2024-02-05 23:04:39
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 1,140 bytes
コンパイル時間 3,349 ms
コンパイル使用メモリ 261,092 KB
実行使用メモリ 372,372 KB
最終ジャッジ日時 2024-02-05 23:04:49
合計ジャッジ時間 10,441 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,676 KB
testcase_01 AC 2 ms
6,676 KB
testcase_02 AC 463 ms
45,440 KB
testcase_03 TLE -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

constexpr std::int64_t MOD = 1e9 + 7;

int main() {
    std::int64_t N, S, K;

    std::cin >> N >> S >> K;

    std::vector<std::vector<std::map<std::int64_t, std::int64_t>>> dp(N + 1, std::vector<std::map<std::int64_t, std::int64_t>>(S + 1));

    // endo
    for (auto i : std::views::iota(0, S + 1))
        dp[0][i][i] = 1;

    std::int64_t result = 0;
    
    for (auto i : std::views::iota(1, N)) {
        for (auto j : std::views::iota(K, S + 1)) {
            if (j > 0)
                for (auto [index, value] : dp[i][j - 1]) {
                   if (index <= S) 
                        dp[i][j][index + 1] = (dp[i][j][index + 1] + value) % MOD;
                }
            
            for (auto [index, value] : dp[i - 1][j - K]) {
                if (index + j <= S) 
                    dp[i][j][index + j] = (dp[i][j][index + j] + value) % MOD;
            }
        }

        // release
        dp[i - 1].clear();
    }

    for (auto j : std::views::iota(K, S + 1)) {
        result = (result + dp[N - 1][j][S]) % MOD;
    }
    
    std::cout << result << std::endl;
    
    return 0;
}
0