結果

問題 No.269 見栄っ張りの募金活動
ユーザー htensaihtensai
提出日時 2020-05-12 13:29:51
言語 Java21
(openjdk 21)
結果
TLE  
実行時間 -
コード長 1,072 bytes
コンパイル時間 2,214 ms
コンパイル使用メモリ 75,480 KB
実行使用メモリ 62,344 KB
最終ジャッジ日時 2023-10-11 12:21:01
合計ジャッジ時間 9,895 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 122 ms
56,048 KB
testcase_01 AC 123 ms
55,876 KB
testcase_02 AC 121 ms
56,156 KB
testcase_03 AC 430 ms
62,344 KB
testcase_04 TLE -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
権限があれば一括ダウンロードができます

ソースコード

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;
		HashMap<Integer, Integer> map = new HashMap<>();
		for (int i = 0; i * n <= s; i++) {
		    map.put(i * n, 1);
		}
		for (int i = 2; i <= n; i++) {
		    HashMap<Integer, Integer> next = new HashMap<>();
		    for (Map.Entry<Integer, Integer> entry : map.entrySet()) {
		        int key = entry.getKey();
		        int value = entry.getValue();
		        for (int j = 0; key + j * (n - i + 1) <= s; j++) {
		            int nkey = key + j * (n - i + 1);
		            if (next.containsKey(nkey)) {
		                next.put(nkey, (next.get(nkey) + value) % MOD);
		            } else {
		                next.put(nkey, value);
		            }
		        }
		    }
		    map = next;
		}
		System.out.println(map.get(s));
	}
}
0