結果

問題 No.269 見栄っ張りの募金活動
ユーザー trmr105trmr105
提出日時 2020-07-30 14:34:40
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 23 ms / 5,000 ms
コード長 1,239 bytes
コンパイル時間 1,625 ms
コンパイル使用メモリ 171,036 KB
実行使用メモリ 19,448 KB
最終ジャッジ日時 2023-09-17 03:06:08
合計ジャッジ時間 2,630 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 3 ms
4,380 KB
testcase_04 AC 10 ms
9,540 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 23 ms
19,448 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 10 ms
10,124 KB
testcase_10 AC 1 ms
4,380 KB
testcase_11 AC 3 ms
4,980 KB
testcase_12 AC 9 ms
8,540 KB
testcase_13 AC 4 ms
5,196 KB
testcase_14 AC 2 ms
4,376 KB
testcase_15 AC 4 ms
4,836 KB
testcase_16 AC 9 ms
8,052 KB
testcase_17 AC 3 ms
4,380 KB
testcase_18 AC 16 ms
13,096 KB
testcase_19 AC 5 ms
5,716 KB
testcase_20 AC 2 ms
4,380 KB
testcase_21 AC 3 ms
4,380 KB
testcase_22 AC 3 ms
4,376 KB
testcase_23 AC 2 ms
4,376 KB
testcase_24 AC 2 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

using ll = long long;
using Field = vector<vector<ll>>;
using Graph = vector<vector<ll>>;
using VI = vector<int>;
using VL = vector<ll>;
using VVL = vector<vector<ll>>;
using VC = vector<char>;
using PI = pair<int, int>;

#define FOR(i, s, n) for (int i = s; i < (n); i++)
#define REP(i, n) for (int i = 0; i < (n); i++)
#define ALL(x) x.begin(), x.end()

const long long INF = 1LL<<60;
const int mod = 1000000007;

template<class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }

ll N, S, K;
VVL dp;

int main() {
    cin.tie(0);
    ios_base::sync_with_stdio(false);

    cin >> N >> S >> K;

    dp.assign(N+1, VL(S+1));

    dp[0][0] = 1;

    for (int i = 0; i < N; i++) {
        for (int j = 0; j <= S; j++) {
            if (i && j >= K * (N - i)) {
                dp[i][j] += dp[i - 1][j - K * (N - i)];
                dp[i][j] %= mod;
            }
            if (j >= N - i) {
                dp[i][j] += dp[i][j - (N - i)];
                dp[i][j] %= mod;
            }
        }
    }

    cout << dp[N-1][S] << endl;






    return 0;
}
0