結果

問題 No.269 見栄っ張りの募金活動
ユーザー shung11260shung11260
提出日時 2019-11-05 08:28:31
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 28 ms / 5,000 ms
コード長 852 bytes
コンパイル時間 2,327 ms
コンパイル使用メモリ 62,372 KB
実行使用メモリ 19,468 KB
最終ジャッジ日時 2023-10-13 02:14:47
合計ジャッジ時間 2,774 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,348 KB
testcase_01 AC 1 ms
4,352 KB
testcase_02 AC 2 ms
4,352 KB
testcase_03 AC 2 ms
4,352 KB
testcase_04 AC 10 ms
9,080 KB
testcase_05 AC 2 ms
4,348 KB
testcase_06 AC 1 ms
4,356 KB
testcase_07 AC 28 ms
19,468 KB
testcase_08 AC 1 ms
4,348 KB
testcase_09 AC 2 ms
4,348 KB
testcase_10 AC 1 ms
4,348 KB
testcase_11 AC 4 ms
4,504 KB
testcase_12 AC 2 ms
4,352 KB
testcase_13 AC 4 ms
5,016 KB
testcase_14 AC 2 ms
4,348 KB
testcase_15 AC 4 ms
4,820 KB
testcase_16 AC 1 ms
4,352 KB
testcase_17 AC 1 ms
4,348 KB
testcase_18 AC 10 ms
8,864 KB
testcase_19 AC 4 ms
4,560 KB
testcase_20 AC 2 ms
4,352 KB
testcase_21 AC 2 ms
4,352 KB
testcase_22 AC 3 ms
4,368 KB
testcase_23 AC 2 ms
4,352 KB
testcase_24 AC 2 ms
4,352 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>

using namespace std;

const long long int MOD=1e9+7;

int main() {
    int N;
    long long int S, K;
    cin >> N >> S >> K;
    
    long long int M=S-((N-1)*N)/2*K;
    // cout << M << endl;
    if(M<0) {
        cout << 0 << endl;
        return 0;
    }
    vector<vector<long long int> > dp(N+1, vector<long long int>(M+1, 0));
    dp[0][0]=1;
    for(int m=0; m<M+1; m++) {
        for(int n=1; n<N+1; n++) {
            if(m-n>=0) {
                dp[n][m] = (dp[n][m-n] + dp[n-1][m])%MOD;
            } else {
                dp[n][m] = dp[n-1][m]%MOD;
            }
        }
    }
    
    // for(int n=0; n<N+1; n++) {
    //     for(int m=0; m<M+1; m++) {
    //         cout << dp[n][m] << " ";
    //     }
    //     cout << endl;
    // }
    
    cout << dp[N][M] << endl;

    return 0;
    
}
0