結果
問題 | No.269 見栄っ張りの募金活動 |
ユーザー |
|
提出日時 | 2019-06-20 16:20:30 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 11 ms / 5,000 ms |
コード長 | 2,094 bytes |
コンパイル時間 | 634 ms |
コンパイル使用メモリ | 63,480 KB |
実行使用メモリ | 18,704 KB |
最終ジャッジ日時 | 2024-12-17 18:54:24 |
合計ジャッジ時間 | 1,519 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 22 |
ソースコード
#include <iostream>#include <vector>#include <string>#include <utility>#include <algorithm>using namespace std;// typedeftypedef long long ll;// container util#define ALL(c) (c).begin(),(c).end()#define RALL(c) (c).rbegin(), (c).rend()#define PB push_back#define EB emplace_back#define MP make_pair#define SZ(c) int((c).size())#define EACH(i,c) for(auto (i)=(c).begin(); (i)!=(c).end(); ++(i))#define EXIST(s,e) ((s).find(e)!=(s).end())#define SORT(c) sort(ALL(c))// repetition#define FOR(i,m,n) for(ll (i) = ((ll) m); (i) < ((ll) n); ++(i))#define RFOR(i,m,n) for(ll (i) = ((ll) (m)-1); (i) >= ((ll) n); --(i))#define REP(i,n) FOR(i,0,n)// i/o#define TFOUT(b,t,f) cout << ((b)? (t) : (f)) << endl// constantconst double EPS = 1e-10;const int INFTY = (1<<21);const ll MOD = (ll) 1e9+7;// clear memory#define CLR(a) memset((a),0,sizeof(a))// debug#define dump(x) cerr << #x << " = " << (x) << endl#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ") " << " " << __FILE__ << endlint main() {int n, s, k; cin >> n >> s >> k;int m = s - k*(n-1)*n/2;if(m < 0) {cout << 0 << endl;return 0;}vector<ll> dp((m+1)*n, 0);REP(i, n) {REP(j, m+1) {if (i == 0) {dp[i*(m+1)+j] = 1;continue;}ll val = dp[(i-1)*(m+1)+j];if (j-i-1 >= 0) val += dp[i*(m+1)+j-i-1];dp[i*(m+1)+j] = val % MOD;}}cout << *(dp.end() - 1) << endl;return 0;}/*見栄っ張りの募金活動https://yukicoder.me/problems/no/269数字の間の差が一定以上であれという制約がある分割の問題は,各数字(ai)が取りうる最小値(mi)の和Mを一致させたい和Sからあらかじめ引いておいて,その上でSの分割を求めれば良い. ある分割{bi}が得られたらそれをソートしてai = mi + biとすれば良い. すなわち(順序をもたない)分割{bi}が順序付きの列(ai)に一対一で対応する.*/