結果

問題 No.269 見栄っ張りの募金活動
ユーザー HIcoderHIcoder
提出日時 2023-10-10 23:34:31
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,037 bytes
コンパイル時間 1,871 ms
コンパイル使用メモリ 104,580 KB
実行使用メモリ 19,508 KB
最終ジャッジ日時 2023-10-10 23:34:36
合計ジャッジ時間 4,149 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,372 KB
testcase_01 AC 2 ms
4,368 KB
testcase_02 AC 2 ms
4,372 KB
testcase_03 AC 3 ms
4,372 KB
testcase_04 AC 15 ms
9,312 KB
testcase_05 AC 3 ms
4,368 KB
testcase_06 AC 1 ms
4,372 KB
testcase_07 AC 32 ms
19,508 KB
testcase_08 AC 2 ms
4,368 KB
testcase_09 AC 2 ms
4,372 KB
testcase_10 WA -
testcase_11 AC 5 ms
4,820 KB
testcase_12 AC 2 ms
4,368 KB
testcase_13 AC 6 ms
5,272 KB
testcase_14 AC 4 ms
4,376 KB
testcase_15 AC 6 ms
5,228 KB
testcase_16 AC 2 ms
4,372 KB
testcase_17 AC 2 ms
4,372 KB
testcase_18 AC 12 ms
8,872 KB
testcase_19 AC 5 ms
5,072 KB
testcase_20 AC 3 ms
4,368 KB
testcase_21 AC 5 ms
4,372 KB
testcase_22 AC 6 ms
4,600 KB
testcase_23 AC 3 ms
4,372 KB
testcase_24 AC 3 ms
4,368 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

/*

*/
#include<iostream>
#include<set>
#include<algorithm>
#include<vector>
#include<string>
#include<set>
#include<map>
#include<stack>
#include<numeric>
#include<queue>
#include<cmath>
#include<deque>
using namespace std;
typedef long long ll;
const ll INF=1LL<<60;
typedef pair<int,int> P;
typedef pair<ll,P> PP;
const ll MOD=1e9+7;

int main(){
    ll N,S,K;
    cin>>N>>S>>K;

    S=S-K*N*(N-1)/2;
    if(S<=0){
        cout<<0<<endl;
        return 0;
    }
    vector<vector<ll>> dp(S+1,vector<ll>(N+1,0));
    dp[0][0]=1;//0個のものを0人で分け与える
    /*
    for(int k=0;k<=S;k++){
        //k個の者を0個で分割
        dp[k][0]=1;
    }
    */

    for(int i=0;i<=S;i++){
        for(int j=1;j<=N;j++){
            if(i-j>=0){
                //i-j個の者をj個で分割
                dp[i][j]+=dp[i-j][j];
                dp[i][j]%=MOD;
            }
            //i個の者をj-1個で分割
            dp[i][j]+=dp[i][j-1];
            dp[i][j]%=MOD;
        }
    }

    cout<<dp[S][N]<<endl;

}
0