結果

問題 No.269 見栄っ張りの募金活動
ユーザー naribownaribow
提出日時 2020-08-11 18:06:01
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 11 ms / 5,000 ms
コード長 997 bytes
コンパイル時間 1,797 ms
コンパイル使用メモリ 167,216 KB
実行使用メモリ 11,264 KB
最終ジャッジ日時 2024-04-17 17:28:30
合計ジャッジ時間 2,391 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,816 KB
testcase_01 AC 2 ms
6,940 KB
testcase_02 AC 2 ms
6,940 KB
testcase_03 AC 2 ms
6,944 KB
testcase_04 AC 5 ms
6,948 KB
testcase_05 AC 2 ms
6,940 KB
testcase_06 AC 2 ms
6,940 KB
testcase_07 AC 11 ms
11,264 KB
testcase_08 AC 2 ms
6,944 KB
testcase_09 AC 1 ms
6,940 KB
testcase_10 AC 1 ms
6,940 KB
testcase_11 AC 2 ms
6,944 KB
testcase_12 AC 1 ms
6,940 KB
testcase_13 AC 3 ms
6,940 KB
testcase_14 AC 2 ms
6,940 KB
testcase_15 AC 2 ms
6,944 KB
testcase_16 AC 2 ms
6,940 KB
testcase_17 AC 1 ms
6,940 KB
testcase_18 AC 5 ms
6,944 KB
testcase_19 AC 3 ms
6,944 KB
testcase_20 AC 2 ms
6,944 KB
testcase_21 AC 2 ms
6,940 KB
testcase_22 AC 2 ms
6,940 KB
testcase_23 AC 2 ms
6,940 KB
testcase_24 AC 2 ms
6,944 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const double pi=3.141592653589793;
typedef unsigned long long ull;
typedef long double ldouble;
const ll INF=1e18;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }


int main(){
    int N, S, K, mod = 1e9+7;
    cin >> N >> S >> K;
    if(N * (N-1) / 2 * K > S) {
        cout << 0 << endl;
        return 0;
    }
    int M = N;
    N = S - K * (N-1) * N / 2;
    vector<vector<int> > dp(M+1, vector<int>(N+1));
    dp[0][0] = 1;
    rep2(i, 1, M+1){
        rep(j, N+1){
            if(j-i >= 0) {
                dp[i][j] = (dp[i-1][j] + dp[i][j-i]) % mod;
            } else {
                dp[i][j] = dp[i-1][j];
            }
        }
    }
    cout << dp[M][N] << endl;
}
0