結果

問題 No.269 見栄っ張りの募金活動
ユーザー 👑 potato167potato167
提出日時 2020-12-08 14:25:53
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 57 ms / 5,000 ms
コード長 503 bytes
コンパイル時間 1,921 ms
コンパイル使用メモリ 171,992 KB
実行使用メモリ 20,224 KB
最終ジャッジ日時 2023-10-17 17:13:44
合計ジャッジ時間 3,029 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 1 ms
4,348 KB
testcase_03 AC 4 ms
4,348 KB
testcase_04 AC 22 ms
9,928 KB
testcase_05 AC 2 ms
4,348 KB
testcase_06 AC 2 ms
4,348 KB
testcase_07 AC 57 ms
20,224 KB
testcase_08 AC 2 ms
4,348 KB
testcase_09 AC 2 ms
4,348 KB
testcase_10 AC 2 ms
4,348 KB
testcase_11 AC 7 ms
5,440 KB
testcase_12 AC 1 ms
4,348 KB
testcase_13 AC 8 ms
5,756 KB
testcase_14 AC 5 ms
4,648 KB
testcase_15 AC 8 ms
5,572 KB
testcase_16 AC 2 ms
4,348 KB
testcase_17 AC 2 ms
4,348 KB
testcase_18 AC 21 ms
9,412 KB
testcase_19 AC 8 ms
5,436 KB
testcase_20 AC 3 ms
4,348 KB
testcase_21 AC 4 ms
4,456 KB
testcase_22 AC 6 ms
4,952 KB
testcase_23 AC 2 ms
4,348 KB
testcase_24 AC 4 ms
4,536 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll=long long;
ll I=167167167167;
ll Q=1e9+7;

vector<vector<ll>> vec2(ll a,ll b,ll syoki){
  vector<vector<ll>> c(a,vector<ll>(b,syoki));
  return c;
}

int main() {
	ll N,S,K;
	cin>>N>>S>>K;
	S-=(K*N*(N-1))/2;
	if(S<0){
		cout<<"0"<<endl;
		return 0;
	}
	auto dp=vec2(S+2*N,N+2,0);
	dp[0][0]=1;
	for(int i=0;i<=S;i++){
		for(int j=0;j<=N;j++){
			dp[i][j]%=Q;
			if(j!=0) dp[i+j][j]+=dp[i][j];
			dp[i][j+1]+=dp[i][j];
		}
	}
	cout<<dp[S][N]<<endl;
}
0