結果

問題 No.269 見栄っ張りの募金活動
ユーザー HIcoderHIcoder
提出日時 2023-10-10 23:39:44
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 27 ms / 5,000 ms
コード長 935 bytes
コンパイル時間 1,241 ms
コンパイル使用メモリ 104,300 KB
実行使用メモリ 19,392 KB
最終ジャッジ日時 2023-10-10 23:39:47
合計ジャッジ時間 2,504 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,352 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 2 ms
4,356 KB
testcase_03 AC 2 ms
4,352 KB
testcase_04 AC 11 ms
9,428 KB
testcase_05 AC 2 ms
4,352 KB
testcase_06 AC 2 ms
4,348 KB
testcase_07 AC 27 ms
19,392 KB
testcase_08 AC 2 ms
4,356 KB
testcase_09 AC 1 ms
4,352 KB
testcase_10 AC 2 ms
4,348 KB
testcase_11 AC 4 ms
4,856 KB
testcase_12 AC 1 ms
4,352 KB
testcase_13 AC 5 ms
5,204 KB
testcase_14 AC 3 ms
4,356 KB
testcase_15 AC 5 ms
5,308 KB
testcase_16 AC 2 ms
4,356 KB
testcase_17 AC 2 ms
4,348 KB
testcase_18 AC 10 ms
8,836 KB
testcase_19 AC 4 ms
5,024 KB
testcase_20 AC 3 ms
4,356 KB
testcase_21 AC 4 ms
4,352 KB
testcase_22 AC 4 ms
4,596 KB
testcase_23 AC 1 ms
4,352 KB
testcase_24 AC 3 ms
4,372 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 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