結果

問題 No.269 見栄っ張りの募金活動
ユーザー nishifeodanishifeoda
提出日時 2021-02-11 16:57:08
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 1,518 ms / 5,000 ms
コード長 712 bytes
コンパイル時間 565 ms
コンパイル使用メモリ 70,392 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-25 06:37:03
合計ジャッジ時間 6,936 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,384 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 6 ms
4,376 KB
testcase_04 AC 1,082 ms
4,380 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 1,518 ms
4,380 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 1 ms
4,380 KB
testcase_11 AC 490 ms
4,380 KB
testcase_12 AC 2 ms
4,376 KB
testcase_13 AC 205 ms
4,380 KB
testcase_14 AC 406 ms
4,380 KB
testcase_15 AC 300 ms
4,380 KB
testcase_16 AC 2 ms
4,376 KB
testcase_17 AC 1 ms
4,376 KB
testcase_18 AC 305 ms
4,380 KB
testcase_19 AC 98 ms
4,376 KB
testcase_20 AC 74 ms
4,380 KB
testcase_21 AC 341 ms
4,376 KB
testcase_22 AC 71 ms
4,376 KB
testcase_23 AC 3 ms
4,376 KB
testcase_24 AC 201 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#define repeat(i,n) for (int i = 0; (i) < (n); ++(i))
#define repeat_reverse(i,n) for (int i = (n)-1; (i) >= 0; --(i))
using namespace std;
const int mod = 1e9 + 7;
int main() {
    int n, s, k; cin >> n >> s >> k;
    s -= k * (n - 1) * n / 2;
    if (s < 0) {
        cout << 0 << endl;
    }
    else {
        vector<int> dp(s + 1);
        dp[0] = 1;
        repeat(i, n) {
            repeat_reverse(j, s + 1) {
                for (int a = 1; j + a * (n - i) < s + 1; ++a) {
                    dp[j + a * (n - i)] += dp[j];
                    dp[j + a * (n - i)] %= mod;
                }
            }
        }
        cout << dp[s] << endl;
    }
    return 0;
}
0