結果

問題 No.269 見栄っ張りの募金活動
ユーザー finefine
提出日時 2016-04-03 01:18:20
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 4,679 ms / 5,000 ms
コード長 697 bytes
コンパイル時間 2,460 ms
コンパイル使用メモリ 148,512 KB
実行使用メモリ 19,472 KB
最終ジャッジ日時 2023-09-23 01:19:30
合計ジャッジ時間 19,060 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 13 ms
4,376 KB
testcase_04 AC 3,299 ms
9,016 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 4,679 ms
19,472 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 1 ms
4,376 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 1,588 ms
4,632 KB
testcase_12 AC 1 ms
4,376 KB
testcase_13 AC 677 ms
4,876 KB
testcase_14 AC 1,354 ms
4,376 KB
testcase_15 AC 966 ms
4,868 KB
testcase_16 AC 1 ms
4,376 KB
testcase_17 AC 1 ms
4,384 KB
testcase_18 AC 994 ms
8,564 KB
testcase_19 AC 320 ms
4,560 KB
testcase_20 AC 244 ms
4,376 KB
testcase_21 AC 1,145 ms
4,380 KB
testcase_22 AC 234 ms
4,380 KB
testcase_23 AC 6 ms
4,376 KB
testcase_24 AC 670 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    const long long MOD = 1000000007;
    int n, s, k;
    cin >> n >> s >> k;
    if (s >= n * (n - 1) * k / 2) s -= n * (n - 1) * k / 2;
    else {
        cout << 0 << "\n";
        return 0;
    }
    vector< vector<long long> > dp(n + 1, vector<long long>(s + 1,0)); 
    dp[0][0] = 1;
    for(int i = 1; i <= n; i++) {
        for(int j = 0; j <= s; j++) {
            for(int t = 0; t * (n - i + 1) <= j; t++) {
                dp[i][j] += dp[i - 1][j - (n - i + 1) * t];
                dp[i][j] %= MOD;
            }
        }
    }
    cout << dp[n][s] << "\n";
    return 0;
}
0