結果
問題 | No.269 見栄っ張りの募金活動 |
ユーザー |
![]() |
提出日時 | 2020-06-05 22:06:51 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 20 ms / 5,000 ms |
コード長 | 1,803 bytes |
コンパイル時間 | 1,705 ms |
コンパイル使用メモリ | 170,780 KB |
実行使用メモリ | 11,776 KB |
最終ジャッジ日時 | 2024-12-17 15:19:20 |
合計ジャッジ時間 | 2,691 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 22 |
ソースコード
#include<bits/stdc++.h>using namespace std;#define arep(i,x,n) for(int i=int(x);i<(int)(n);i++)#define rep(i,n) for(long long i = 0;i < n;++i)#define rrep(i,n) for(int i=int(n-1);i>=0;i--)#define fs first#define sc second#define all(x) (x).begin(), (x).end()#define pi 3.141592653589793#define eps 0.00000001#define INF 1e9+7using ll = long long;using P=pair<int,int>;using lP=pair<ll,ll>;using fP=pair<double,double>;using PPI=pair<P,int>;//ll const mod=998244353;ll const mod=1e9+7;const ll MAX=300000;using vi=vector<int>;using vl=vector<ll>;using vc=vector<char>;using vd=vector<double>;using vs=vector<string>;using vp=vector<P>;using vb=vector<bool>;using vvi =vector<vector<int>>;using vvd=vector<vector<double>>;using vvc=vector<vector<char>>;using vvp =vector<vector<P>>;using vvb=vector<vector<bool>>;template <typename T>bool chmax(T &a, const T b){if(a < b){a = b; return true;} return false;}template <typename T>bool chmin(T &a, const T b){if(a > b){a = b; return true;} return false;}//https://drken1215.hatenablog.com/entry/2018/01/16/222843//////////////////////////////////////int main(){int n,s,k;cin>>n>>s>>k;int atleast=k*n*(n-1)/2;s-=atleast;ll ans=0;if(s<0){cout<<ans<<endl;return 0;}else if(s==0){cout<<1<<endl;return 0;}int all=s;vvi dp(all+1,vi(n+1));dp[0][0]=1;//初期化は[i][i]への遷移を意識arep(i,0,all+1){//出来れば文字は逆の方がいいarep(j,1,n+1){if(i-j>=0)dp[i][j]=dp[i][j-1]+dp[i-j][j];//通常else dp[i][j]=dp[i][j-1];//もう全部に1個ずつは足りない。dp[i][j]%=mod;}}cout<<dp[all][n]<<endl;return 0;}