結果

問題 No.269 見栄っ張りの募金活動
ユーザー ummaaaummaaa
提出日時 2020-08-17 18:39:14
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 12 ms / 5,000 ms
コード長 1,071 bytes
コンパイル時間 2,301 ms
コンパイル使用メモリ 275,212 KB
実行使用メモリ 12,288 KB
最終ジャッジ日時 2024-04-19 19:01:22
合計ジャッジ時間 3,139 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 4 ms
12,160 KB
testcase_01 AC 4 ms
12,032 KB
testcase_02 AC 5 ms
12,032 KB
testcase_03 AC 4 ms
12,016 KB
testcase_04 AC 8 ms
12,160 KB
testcase_05 AC 4 ms
12,032 KB
testcase_06 AC 5 ms
12,032 KB
testcase_07 AC 12 ms
12,020 KB
testcase_08 AC 5 ms
12,160 KB
testcase_09 AC 5 ms
12,160 KB
testcase_10 AC 3 ms
12,160 KB
testcase_11 AC 5 ms
12,032 KB
testcase_12 AC 4 ms
12,032 KB
testcase_13 AC 5 ms
12,032 KB
testcase_14 AC 4 ms
12,160 KB
testcase_15 AC 5 ms
12,032 KB
testcase_16 AC 5 ms
12,288 KB
testcase_17 AC 4 ms
12,136 KB
testcase_18 AC 7 ms
12,032 KB
testcase_19 AC 4 ms
12,220 KB
testcase_20 AC 5 ms
12,032 KB
testcase_21 AC 6 ms
12,040 KB
testcase_22 AC 5 ms
12,160 KB
testcase_23 AC 4 ms
12,160 KB
testcase_24 AC 4 ms
12,260 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#include <x86intrin.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#define V vector
template <typename T> bool chmin(T &a, const T &b) {if(a > b){a = b; return true;} return false;}
template <typename T> bool chmax(T &a, const T &b) {if(a < b){a = b; return true;} return false;}
V<int> dx = {-1, 1,  0, 0, -1, -1,  1, 1};
V<int> dy = { 0, 0, -1, 1, -1,  1, -1, 1};

const int mod = 1e9 + 7;
int dp[20010][110];

int main () {
    int n, s, k; cin >> n >> s >> k;
    memset(dp, 0, sizeof(dp));
    s -= (n-1) * n / 2 * k;
    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 >= 0) dp[i][j] = dp[i][j-1] + dp[i-j][j];
            else dp[i][j] = dp[i][j-1];
            dp[i][j] %= mod;
        }
    }
    cout << dp[s][n] << endl;
    return 0;
}
0