結果

問題 No.269 見栄っ張りの募金活動
ユーザー morimariomorimario
提出日時 2021-02-20 05:00:13
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 22 ms / 5,000 ms
コード長 4,484 bytes
コンパイル時間 2,155 ms
コンパイル使用メモリ 206,516 KB
実行使用メモリ 12,044 KB
最終ジャッジ日時 2023-10-17 08:49:29
合計ジャッジ時間 3,258 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 2 ms
4,348 KB
testcase_04 AC 10 ms
7,028 KB
testcase_05 AC 2 ms
4,348 KB
testcase_06 AC 2 ms
4,348 KB
testcase_07 AC 22 ms
12,044 KB
testcase_08 AC 2 ms
4,348 KB
testcase_09 AC 2 ms
4,348 KB
testcase_10 AC 2 ms
4,348 KB
testcase_11 AC 4 ms
4,652 KB
testcase_12 AC 2 ms
4,348 KB
testcase_13 AC 4 ms
4,780 KB
testcase_14 AC 3 ms
4,388 KB
testcase_15 AC 4 ms
4,708 KB
testcase_16 AC 2 ms
4,348 KB
testcase_17 AC 2 ms
4,348 KB
testcase_18 AC 9 ms
6,504 KB
testcase_19 AC 4 ms
4,592 KB
testcase_20 AC 2 ms
4,348 KB
testcase_21 AC 4 ms
4,348 KB
testcase_22 AC 3 ms
4,368 KB
testcase_23 AC 2 ms
4,348 KB
testcase_24 AC 3 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
using ll = long long; using ull = unsigned long long; using pil = pair<int, ll>; using pli = pair<ll, int>;
template <typename T> using piT = pair<int, T>; template <typename T> using pTi = pair<T, int>; template <typename T> using pTT = pair<T, T>;
using pii = pair<int, int>; using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>;
using pll = pair<ll, ll>; using vl = vector<ll>; using vvl = vector<vl>; using vvvl = vector<vvl>;
using pbb = pair<bool, bool>; using vb = vector<bool>; using vvb = vector<vb>; using vvvb = vector<vvb>;
using pcc = pair<char, char>; using vc = vector<char>; using vvc = vector<vc>; using vvvc = vector<vvc>;
using pss = pair<string, string>; using vs = vector<string>; using vvs = vector<vs>; using vvvs = vector<vvs>;
using pdd = pair<double, double>; using vd = vector<double>; using vvd = vector<vd>; using vvvd = vector<vvd>;
template <typename T> using pq = priority_queue<T, vector<T>>; template <typename T> using pql = priority_queue<T, vector<T>, greater<T>>;
#define rep0(times) for(int counter = 0; counter < (int)(times); ++counter)
#define rep(counter, goal) for (int counter = 0; counter < (int)(goal); ++counter)
#define rep2(counter, start, goal) for (int counter = (int)(start); counter < (int)(goal); ++counter)
#define rep3(counter, start, goal) for (int counter = (int)(start); counter > (int)(goal); --counter)
#define all(container) begin(container), end(container)
template <typename T> bool chmax(T &x, const T &y) { if (x < y) { x = y; return true; } return false; }
template <typename T> bool chmin(T &x, const T &y) { if (x > y) { x = y; return true; } return false; }
void Yn(bool flag) { cout << (flag ? "Yes" : "No") << "\n"; }
void yn(bool flag) { cout << (flag ? "yes" : "no") << "\n"; }
void YN(bool flag) { cout << (flag ? "YES" : "NO") << "\n"; }
void set_prec(const int &digits) { cout << fixed << setprecision(digits); cerr << fixed << setprecision(digits); }
template <typename T> T INF() { return numeric_limits<T>::max(); }
// #include <atcoder/all>
// using namespace atcoder;
// using mint = atcoder::modint1000000007;
// using mint = atcoder::modint998244353;
// using mint = atcoder::modint;
// using pmm = pair<mint, mint>; using vm = vector<mint>; using vvm = vector<vm>; using vvvm = vector<vvm>;
// void pr(const mint &obj) { cerr << obj.val(); }
template <typename T> void pr(const T &obj) { cerr << obj; }
template <typename T, typename ...Ts> void pr(const T &first, const Ts &...rest) { pr(first); pr(", "); pr(rest...); }
template <typename S, typename T> void pr(const pair<S, T> &pair) { pr("("); pr(pair.first); pr(", "); pr(pair.second); pr(")"); }
template <typename T> void pr(const vector<T> &vec) { pr("{"); for (T obj : vec) { pr(obj); pr(", "); } pr("}"); }
template <typename T> void pr(const vector<vector<T>> &vv) { pr("\n"); rep(index, vv.size()) { pr("["); pr(index); pr("]: "); pr(vv[index]); pr("\n"); } }
template <typename T> void pr(const set<T> &vec) { pr("{"); for (T obj : vec) { pr(obj); pr(", "); } pr("}"); }
template <typename S, typename T> void pr(const map<S, T> &map) { pr("{"); for (pair<S, T> pair : map) { pr("("); pr(pair.first); pr(": "); pr(pair.second); pr("), "); } pr("}"); }
#define db(obj) cerr << #obj << ": "; pr(obj); cerr << " "
#define dl(obj) db(obj); cerr << "\n"
#define dm(...) cerr << "(" << #__VA_ARGS__ << "): ("; pr(__VA_ARGS__); cerr << ") "
#define dml(...) dm(__VA_ARGS__); cerr << "\n"
const ll MOD = 1000000007;
// const ll MOD = 998244353;

// M = S - K * ((N-1) * N / 2)
// Σa[i] = M となるような非減少整数列a[i]の個数が答え
// これは、非負整数MをN個の非負整数(順序を考慮しない)の和で表す方法の数に等しい
// dp[i][j]: iをj個の非負整数の和で表す方法(順序を考慮しない)の数
//  (= iをj個以下の正整数で表す方法(順序を考慮しない)の数) とする
// dp[0][j] = 1;
// dp[i][j] = dp[i][j-1] + dp[i-j][j]

int 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;
	}
	vvi dp(M + 1, vi(N + 1));
	rep(j, N + 1) dp[0][j] = 1;
	// dl(dp); //
	rep2(i, 1, M + 1) {
		rep(j, N + 1) {
			if (j == 0) dp[i][j] = 0;
			else {
				if (j <= i) dp[i][j] = (dp[i][j - 1] + dp[i - j][j]) % MOD;
				else dp[i][j] = dp[i][j - 1];
			}
		}
		// dl(dp); //
	}
	// dl(dp);
	cout << dp[M][N] << endl;
}
0