結果

問題 No.269 見栄っ張りの募金活動
ユーザー 千代裕介千代裕介
提出日時 2020-05-14 03:50:11
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 13 ms / 5,000 ms
コード長 826 bytes
コンパイル時間 1,393 ms
コンパイル使用メモリ 164,372 KB
実行使用メモリ 12,080 KB
最終ジャッジ日時 2023-10-12 17:15:05
合計ジャッジ時間 2,789 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,352 KB
testcase_01 AC 1 ms
4,348 KB
testcase_02 AC 1 ms
4,352 KB
testcase_03 AC 2 ms
4,348 KB
testcase_04 AC 11 ms
11,580 KB
testcase_05 AC 2 ms
4,348 KB
testcase_06 AC 2 ms
4,348 KB
testcase_07 AC 13 ms
11,988 KB
testcase_08 AC 2 ms
4,352 KB
testcase_09 AC 1 ms
4,348 KB
testcase_10 AC 1 ms
4,352 KB
testcase_11 AC 10 ms
10,056 KB
testcase_12 AC 1 ms
4,352 KB
testcase_13 AC 7 ms
7,124 KB
testcase_14 AC 11 ms
12,080 KB
testcase_15 AC 8 ms
8,056 KB
testcase_16 AC 2 ms
4,348 KB
testcase_17 AC 1 ms
4,348 KB
testcase_18 AC 6 ms
7,424 KB
testcase_19 AC 5 ms
5,844 KB
testcase_20 AC 5 ms
6,180 KB
testcase_21 AC 10 ms
10,500 KB
testcase_22 AC 5 ms
5,596 KB
testcase_23 AC 2 ms
4,352 KB
testcase_24 AC 7 ms
8,060 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

// 5/13
// 分割数 類題
// 見栄っ張りの募金活動
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
using Graph = vector<vector<int>>;

int dp[20010][110];  // dp[i][k] = 合計i円をj人で分けるパターン。
const int MOD = 1000000007;

int main() {
    int N, S, K;
    cin >> N >> S >> K;

    S -= K * N * (N - 1) / 2;

    if (S < 0) {
        cout << "0" << endl;
        return 0;
    }

    dp[0][0] = 1;

    for (int i = 0; i <= S; i++) {
        for (int j = 1; j <= N; j++) {
            if (i >= j) {
                dp[i][j] = (dp[i - j][j] + dp[i][j - 1]) % MOD;
            } else {
                dp[i][j] = dp[i][j - 1];
            }            
        }
    }

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