結果
| 問題 |
No.269 見栄っ張りの募金活動
|
| コンテスト | |
| ユーザー |
selous_
|
| 提出日時 | 2022-08-26 18:54:41 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,538 bytes |
| コンパイル時間 | 1,511 ms |
| コンパイル使用メモリ | 172,940 KB |
| 実行使用メモリ | 19,584 KB |
| 最終ジャッジ日時 | 2024-10-13 19:49:11 |
| 合計ジャッジ時間 | 16,642 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 WA * 2 |
| other | AC * 9 WA * 13 |
ソースコード
#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)*(K+num)<=S){
dp[0][(N)*(K+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;
}
selous_