結果

問題 No.269 見栄っ張りの募金活動
ユーザー Manuel1024
提出日時 2021-08-27 06:59:30
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 19 ms / 5,000 ms
コード長 597 bytes
コンパイル時間 702 ms
コンパイル使用メモリ 71,808 KB
実行使用メモリ 19,584 KB
最終ジャッジ日時 2024-11-19 08:05:39
合計ジャッジ時間 1,593 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 22
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
using namespace std;
using ll = long long int;
constexpr ll MOD = 1'000'000'007;

int main(){
    int n, s, k;
    cin >> n >> s >> k;
    vector<vector<ll>> dp(n+1, vector<ll>(s+10, 0));
    dp[0][0] = 1;
    for(int i = 1; i <= n; i++){
        for(int j = 0; j < s+10; j++){
            if(j-i >= 0){
                dp[i][j] = (dp[i-1][j] + dp[i][j-i])%MOD;
            }else{
                dp[i][j] = dp[i-1][j];
            }
        }
    }

    if(s-k*n*(n-1)/2 >= 0) cout << dp[n][s-k*n*(n-1)/2] << endl;
    else cout << 0 << endl;
    return 0;
}
0