結果

問題 No.269 見栄っ張りの募金活動
ユーザー 縣響也縣響也
提出日時 2022-01-22 01:20:04
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 1,353 ms / 5,000 ms
コード長 1,053 bytes
コンパイル時間 2,659 ms
コンパイル使用メモリ 204,916 KB
実行使用メモリ 19,584 KB
最終ジャッジ日時 2024-05-04 19:26:53
合計ジャッジ時間 6,833 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 6 ms
5,376 KB
testcase_04 AC 912 ms
9,216 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 1 ms
5,376 KB
testcase_07 AC 1,353 ms
19,584 KB
testcase_08 AC 2 ms
5,376 KB
testcase_09 AC 2 ms
5,376 KB
testcase_10 AC 2 ms
5,376 KB
testcase_11 AC 377 ms
5,376 KB
testcase_12 AC 2 ms
5,376 KB
testcase_13 AC 176 ms
5,376 KB
testcase_14 AC 143 ms
5,376 KB
testcase_15 AC 245 ms
5,376 KB
testcase_16 AC 2 ms
5,376 KB
testcase_17 AC 2 ms
5,376 KB
testcase_18 AC 278 ms
8,704 KB
testcase_19 AC 81 ms
5,376 KB
testcase_20 AC 50 ms
5,376 KB
testcase_21 AC 167 ms
5,376 KB
testcase_22 AC 58 ms
5,376 KB
testcase_23 AC 3 ms
5,376 KB
testcase_24 AC 135 ms
5,376 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