結果

問題 No.269 見栄っ張りの募金活動
ユーザー KenDoiKenDoi
提出日時 2023-03-22 12:29:42
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 41 ms / 5,000 ms
コード長 1,589 bytes
コンパイル時間 805 ms
コンパイル使用メモリ 97,448 KB
実行使用メモリ 19,204 KB
最終ジャッジ日時 2023-10-18 18:57:19
合計ジャッジ時間 1,886 ms
ジャッジサーバーID
(参考情報)
judge15 / 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 5 ms
4,884 KB
testcase_04 AC 17 ms
9,512 KB
testcase_05 AC 2 ms
4,348 KB
testcase_06 AC 2 ms
4,348 KB
testcase_07 AC 41 ms
19,204 KB
testcase_08 AC 2 ms
4,348 KB
testcase_09 AC 20 ms
10,840 KB
testcase_10 AC 2 ms
4,348 KB
testcase_11 AC 6 ms
5,132 KB
testcase_12 AC 15 ms
9,264 KB
testcase_13 AC 7 ms
5,588 KB
testcase_14 AC 3 ms
4,348 KB
testcase_15 AC 6 ms
5,396 KB
testcase_16 AC 14 ms
8,724 KB
testcase_17 AC 4 ms
4,684 KB
testcase_18 AC 26 ms
13,520 KB
testcase_19 AC 8 ms
6,152 KB
testcase_20 AC 3 ms
4,348 KB
testcase_21 AC 3 ms
4,348 KB
testcase_22 AC 4 ms
4,744 KB
testcase_23 AC 2 ms
4,348 KB
testcase_24 AC 3 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
#include <iostream>
#include <stack>
#include <queue>
#include <algorithm>
#include <functional>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <cmath>
#include<sstream>
#include<list>
#include<iomanip>
#include <cstdlib>
#include <cstring>
#include <stack>
#include <bitset>
#include <cassert>
#include <stdlib.h>
#include <stdio.h>
using namespace std;
const int INF = 100000000;
const long long LINF = 3e18 + 7;
const int MAX_N = 600010;
const int MAX_W = 10002;
const int MAX_ARRAYK = 100000;
double PI = 3.14159265358979323846;
//using ll = long long;


// https://kmjp.hatenablog.jp/entry/2015/08/22/0930


long long dp[110][20010]; // dp[i][T] 生徒iの金額が決まったとき、(以降の生徒が同額払うとして)クラス合計確定金額がT円となる組み合わせ数
long long mod = 1000000007;
int N, S, K;

int main() {
	

	cin >> N >> S >> K;
	for (int k = 0; k <= S; k += N) {
		dp[0][k] = 1;
	}

	for (int i = 1; i < N; i++) {
		
		// t 円にできるか?
		for (int t = 0; t <= S; t++) {
			// (i - 1)番目の人よりK円余分に払う
			if (t >= K * (N - i)) {
				dp[i][t] += dp[i - 1][t - K * (N - i)];
			}

			// 既に全体(t-(N - i))円払っているが
			// もう1円(全体で)N - i円余分に払うケース
			// (単純に普通のdpのインクリメントで一つ前の状態だと考えれば良いと思う)
			if (t >= N - i) {
				dp[i][t] += dp[i][t - (N - i)];
			}

			dp[i][t] %= mod;
			
		}
	}

	cout << dp[N - 1][S] << endl;

	
	return 0;
}
0