結果

問題 No.269 見栄っ張りの募金活動
ユーザー selous_selous_
提出日時 2022-08-26 19:04:44
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 4,820 ms / 5,000 ms
コード長 1,534 bytes
コンパイル時間 1,786 ms
コンパイル使用メモリ 169,360 KB
実行使用メモリ 19,584 KB
最終ジャッジ日時 2024-04-21 21:34:26
合計ジャッジ時間 18,014 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 19 ms
5,376 KB
testcase_04 AC 3,402 ms
9,600 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 4,820 ms
19,584 KB
testcase_08 AC 2 ms
5,376 KB
testcase_09 AC 25 ms
10,240 KB
testcase_10 AC 2 ms
5,376 KB
testcase_11 AC 1,610 ms
5,376 KB
testcase_12 AC 11 ms
8,704 KB
testcase_13 AC 687 ms
5,376 KB
testcase_14 AC 449 ms
5,376 KB
testcase_15 AC 975 ms
5,376 KB
testcase_16 AC 28 ms
8,448 KB
testcase_17 AC 3 ms
5,376 KB
testcase_18 AC 1,205 ms
13,312 KB
testcase_19 AC 359 ms
5,888 KB
testcase_20 AC 215 ms
5,376 KB
testcase_21 AC 721 ms
5,376 KB
testcase_22 AC 233 ms
5,376 KB
testcase_23 AC 8 ms
5,376 KB
testcase_24 AC 578 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
#define pint pair<int,int>
#define pll pair<ll,ll>
const ll modl=1000000007;

using namespace std;
vector<vector<ll>> dp;

int main(void)
{   
	ll N=0,S=0,K=0;
	cin >> N >> S >> K;
	
	//1人目が0円の時、全体で
	// S-=K*(N*(N-1)/2);
	
	// if(S<=0){
	// 	cout << 0 << endl;
	// 	return 0;
	// }
	
	dp.assign(N+1,vector<ll>(S+1,0));
	
	ll num=0;
	// rep(i,0,S+1)	{
	while(1){
		if((N)*(num)<=S){
			dp[0][(N)*(num)]=1;
			num++;
		}		
		else{
			break;
		}		
	}
	
  	// dp[0][0]=1;
	rep(i,0,N-1){
		rep(j,0,S+1){
			num=0;
			if(dp[i][j]!=0){
				while(1){
					if(j+(N-(i+1))*(K+num)<=S){
						dp[i+1][j+(N-(i+1))*(K+num)]+=dp[i][j]%modl;
						dp[i+1][j+(N-(i+1))*(K+num)]%=modl;
						num++;
					}		
					else{
						break;
					}		
				}
			}
			// if(j!=0){
			// 	dp[i+1][j]+=dp[i+1][j-1]%modl;
			// 	dp[i+1][j]%=modl;
			// }
		}
	}
	if(dp[N-1][S]<0)cout << dp[N-1][S]+modl << endl;
	else cout << dp[N-1][S] << endl;
	// cout << endl;
	// rep(i,0,N+1){
	// 	cout << i << ": " ;
	// 	rep(j,0,S+1){
	// 		cout << dp[i][j] << " ";
	// 	}
	// 	cout << endl;
	// }
    return 0;
}   
0