結果

問題 No.269 見栄っ張りの募金活動
ユーザー htensaihtensai
提出日時 2020-05-12 13:19:39
言語 Java21
(openjdk 21)
結果
AC  
実行時間 2,888 ms / 5,000 ms
コード長 832 bytes
コンパイル時間 1,968 ms
コンパイル使用メモリ 74,732 KB
実行使用メモリ 64,876 KB
最終ジャッジ日時 2023-10-11 11:33:26
合計ジャッジ時間 15,173 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 120 ms
56,044 KB
testcase_01 AC 124 ms
56,344 KB
testcase_02 AC 122 ms
56,140 KB
testcase_03 AC 141 ms
55,968 KB
testcase_04 AC 2,054 ms
62,240 KB
testcase_05 AC 137 ms
56,444 KB
testcase_06 AC 121 ms
55,792 KB
testcase_07 AC 2,888 ms
64,876 KB
testcase_08 AC 124 ms
55,764 KB
testcase_09 AC 124 ms
56,284 KB
testcase_10 AC 122 ms
56,068 KB
testcase_11 AC 1,008 ms
58,248 KB
testcase_12 AC 123 ms
55,760 KB
testcase_13 AC 524 ms
56,072 KB
testcase_14 AC 401 ms
56,056 KB
testcase_15 AC 693 ms
56,024 KB
testcase_16 AC 123 ms
55,860 KB
testcase_17 AC 123 ms
56,200 KB
testcase_18 AC 600 ms
57,816 KB
testcase_19 AC 328 ms
54,444 KB
testcase_20 AC 240 ms
56,076 KB
testcase_21 AC 558 ms
54,220 KB
testcase_22 AC 280 ms
55,556 KB
testcase_23 AC 138 ms
55,984 KB
testcase_24 AC 411 ms
55,940 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
    static final int MOD = 1000000007;
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int s = sc.nextInt();
		int kk = sc.nextInt();
		int min = n * (n - 1) * kk / 2;
		if (s < min) {
		    System.out.println(0);
		    return;
		}
		s -= min;
		int[][] dp = new int[n + 1][s + 1];
		dp[0][0] = 1;
		for (int i = 0; i * n <= s; i++) {
		    dp[1][i * n] = 1;
		}
		for (int i = 2; i <= n; i++) {
		    for (int j = 0; j <= s; j++) {
		        if (dp[i - 1][j] == 0) {
		            continue;
		        }
		        for (int k = 0; j + k * (n - i + 1) <= s; k++) {
		            dp[i][j + k * (n - i + 1)] += dp[i - 1][j];
		            dp[i][j + k * (n - i + 1)] %= MOD;
		        }
		    }
		}
		System.out.println(dp[n][s]);
	}
}
0