結果
| 問題 |
No.269 見栄っ張りの募金活動
|
| コンテスト | |
| ユーザー |
kmjp
|
| 提出日時 | 2015-04-08 02:16:17 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
MLE
|
| 実行時間 | - |
| コード長 | 1,148 bytes |
| コンパイル時間 | 1,356 ms |
| コンパイル使用メモリ | 161,584 KB |
| 実行使用メモリ | 616,288 KB |
| 最終ジャッジ日時 | 2024-07-04 10:59:35 |
| 合計ジャッジ時間 | 11,674 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | WA * 2 TLE * 1 |
| other | MLE * 1 -- * 21 |
ソースコード
#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++) {
cout<<i<<endl;
int cur=i&1,tar=cur^1;
ZERO(DP[tar]);
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;
}
kmjp