結果

問題 No.269 見栄っ張りの募金活動
ユーザー 👑 kmjpkmjp
提出日時 2015-04-08 02:18:30
言語 C++11
(gcc 11.4.0)
結果
TLE  
実行時間 -
コード長 1,114 bytes
コンパイル時間 1,141 ms
コンパイル使用メモリ 146,308 KB
実行使用メモリ 210,460 KB
最終ジャッジ日時 2023-09-17 16:03:47
合計ジャッジ時間 9,964 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,404 KB
testcase_01 AC 2 ms
5,492 KB
testcase_02 AC 2,343 ms
83,524 KB
testcase_03 TLE -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef signed long long ll;

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<to;x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

// 実験用の低速コードです。O(N*S^3)。メモリも足りないです
int N,S,K;
ll mo=1000000007;

ll DP[2][5100][5100];

void solve() {
	int i,j,k,l,r,x,y,t; string s;
	
	cin>>N>>S>>K;
	FOR(i,S+1) DP[1][i][i]=1;
	for(i=1;i<N;i++) {
		int cur=i&1,tar=cur^1;
		FOR(t,S+1) FOR(x,t+1) {
			DP[tar][t][x]=0;
			for(j=K;j<=x;j++) DP[tar][t][x]+=DP[cur][t-x][x-j];
			DP[tar][t][x]%=mo;
		}
	}
	
	ll ret=0;
	FOR(i,S+1) ret+=DP[N%2][S][i];
	cout<<ret%mo<<endl;
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false);
	FOR(i,argc-1) s+=argv[i+1],s+='\n';
	FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	solve(); return 0;
}
0