結果

問題 No.269 見栄っ張りの募金活動
ユーザー xuzijian629xuzijian629
提出日時 2018-11-04 14:47:24
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 3,801 ms / 5,000 ms
コード長 1,136 bytes
コンパイル時間 2,432 ms
コンパイル使用メモリ 203,944 KB
実行使用メモリ 19,312 KB
最終ジャッジ日時 2023-09-23 01:37:23
合計ジャッジ時間 20,922 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 7 ms
4,376 KB
testcase_03 AC 55 ms
4,380 KB
testcase_04 AC 2,929 ms
9,360 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 3,801 ms
19,312 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 737 ms
10,212 KB
testcase_10 AC 3 ms
4,376 KB
testcase_11 AC 1,674 ms
4,836 KB
testcase_12 AC 538 ms
8,508 KB
testcase_13 AC 580 ms
5,052 KB
testcase_14 AC 457 ms
4,376 KB
testcase_15 AC 805 ms
4,936 KB
testcase_16 AC 820 ms
7,996 KB
testcase_17 AC 49 ms
4,376 KB
testcase_18 AC 2,572 ms
13,160 KB
testcase_19 AC 596 ms
5,676 KB
testcase_20 AC 179 ms
4,380 KB
testcase_21 AC 531 ms
4,376 KB
testcase_22 AC 195 ms
4,380 KB
testcase_23 AC 12 ms
4,380 KB
testcase_24 AC 419 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using i64 = int64_t;
using vi = vector<i64>;
using vvi = vector<vi>;
constexpr i64 MOD = 1e9 + 7;
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("O3")

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    cout.setf(ios::fixed);
    cout.precision(10);
    int n, s, k;
    cin >> n >> s >> k;

    const int maxS = s + 1;
    vvi dp(n + 1, vi(maxS));
    for (int i = k; i < maxS; i++) {
        dp[1][i] = 1;
    }

    for (int i = 2; i <= n; i++) {
        for (int j = 0; j < maxS; j++) {
            for (int d = k; d < maxS; d++) {
                int rem = j - d * i;
                if (rem >= 0) {
                    dp[i][j] += dp[i - 1][rem];
                    dp[i][j] %= MOD;
                } else {
                    break;
                }
            }
        }
    }

    i64 ans = 0;
    for (int i = 0; i < maxS; i++) {
        int rem = s - i * n;
        if (rem >= 0) {
            ans += dp[n - 1][rem];
            ans %= MOD;
        } else {
            break;
        }
    }
    cout << ans << endl;
}
0