結果

問題 No.269 見栄っ張りの募金活動
ユーザー 縣響也縣響也
提出日時 2022-01-22 01:20:04
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 1,496 ms / 5,000 ms
コード長 1,053 bytes
コンパイル時間 2,025 ms
コンパイル使用メモリ 203,732 KB
実行使用メモリ 19,404 KB
最終ジャッジ日時 2023-08-17 12:47:57
合計ジャッジ時間 7,728 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 5 ms
4,376 KB
testcase_04 AC 1,001 ms
8,852 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 1,496 ms
19,404 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 1 ms
4,376 KB
testcase_10 AC 1 ms
4,376 KB
testcase_11 AC 406 ms
4,468 KB
testcase_12 AC 1 ms
4,376 KB
testcase_13 AC 192 ms
4,880 KB
testcase_14 AC 157 ms
4,380 KB
testcase_15 AC 271 ms
4,952 KB
testcase_16 AC 2 ms
4,376 KB
testcase_17 AC 1 ms
4,376 KB
testcase_18 AC 303 ms
8,692 KB
testcase_19 AC 92 ms
4,564 KB
testcase_20 AC 53 ms
4,376 KB
testcase_21 AC 184 ms
4,376 KB
testcase_22 AC 64 ms
4,380 KB
testcase_23 AC 3 ms
4,380 KB
testcase_24 AC 149 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 60;

#define REP(i, init, n) for(int i = (int)(init); i < (int)(n); i++)

#define vi vector<int>
#define vl vector<long>
#define vvi vector<vector<int>>
#define vvl vector<vector<long>>
#define pint pair<int, int>
#define plong pair<long, long>

int N, S, K;

void solve() {
    S -= K * (N - 1) * N / 2;
    if(S < 0) {
        cout << 0 << endl;
        return;
    }
    vvl dp(N + 1, vl(S + 1, 0));
    dp[0][0] = 1;
    REP(i, 1, N + 1) {
        int add = N + 1 - i;
        REP(j, 0, S + 1) {
            if(i == N) {
                dp[i][S] += dp[i - 1][j];
                dp[i][S] %= mod;
                continue;
            }
            int m = 0;
            while(j + add * m <= S) {
                dp[i][j + add * m] += dp[i - 1][j];
                dp[i][j + add * m] %= mod;
                m++;
            }
        }
    }
    cout << dp[N][S] << endl;
}

int main() {
    cin >> N >> S >> K;
    solve();
}
0