結果

問題 No.269 見栄っ張りの募金活動
ユーザー Yang33Yang33
提出日時 2018-09-20 00:24:55
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 2,238 bytes
コンパイル時間 1,527 ms
コンパイル使用メモリ 169,876 KB
実行使用メモリ 19,424 KB
最終ジャッジ日時 2023-09-25 10:19:02
合計ジャッジ時間 12,099 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 9 ms
4,376 KB
testcase_04 AC 1,907 ms
8,980 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 2,719 ms
19,424 KB
testcase_08 AC 1 ms
4,376 KB
testcase_09 AC 1 ms
4,376 KB
testcase_10 WA -
testcase_11 AC 918 ms
4,380 KB
testcase_12 AC 1 ms
4,376 KB
testcase_13 AC 393 ms
4,836 KB
testcase_14 AC 784 ms
4,376 KB
testcase_15 AC 558 ms
4,912 KB
testcase_16 AC 1 ms
4,380 KB
testcase_17 AC 2 ms
4,376 KB
testcase_18 AC 581 ms
8,640 KB
testcase_19 AC 187 ms
4,736 KB
testcase_20 AC 141 ms
4,376 KB
testcase_21 AC 663 ms
4,376 KB
testcase_22 AC 138 ms
4,376 KB
testcase_23 AC 5 ms
4,376 KB
testcase_24 AC 387 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
#define debug(x) cerr << #x << ": " << x << endl
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  2018/09/19  Problem: yukicoder 269  / Link: http://yukicoder.me/problems/no/269  ----- */
/* ------問題------

学校で募金活動をすることになり、N人のクラスでS円を集め寄付することにした。
生徒は出席番号順に寄付金額(0以上の整数)を決めていく。

このクラスの生徒は皆見栄っ張りであり、出席番号順が1つ前の生徒に比べてK円以上高い金額を寄付しないと気が済まず不満になるようだ。
(最初に金額を決める生徒は比べる相手がいないので何円寄付しても良い。0円でも構わない)

不満な生徒が現れることなく、クラスの合計寄付金額がちょうどS円となるような各生徒の寄付金額の組み合わせは何通りあるか。
組み合わせ数を10^9+7で割った余りを答えよ。

-----問題ここまで----- */
/* -----解説等-----



----解説ここまで---- */

int main() {
	cin.tie(0);
	ios_base::sync_with_stdio(false);

	LL N, S, K; cin >> N >> S >> K;

	S -= K *N* (N - 1) / 2;
	LL ans = 0;
	if (S > 0) {
		VVL dp(N + 1, VL(S+1,0));
		dp[0][0] = 1;

		FOR(i, 0, N) {
			FOR(k, 0, S+1) {
				FOR(s, 0, S+1 - (N-i)*k) {
					(dp[i + 1][s+(N-i)*k] += dp[i][s]) %= MOD;
				}
			}
		}
		ans = dp[N][S];
	}

	cout << ans << "\n";

	return 0;
}
0