結果
問題 | No.269 見栄っ張りの募金活動 |
ユーザー |
![]() |
提出日時 | 2020-05-12 13:29:51 |
言語 | Java (openjdk 23) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,072 bytes |
コンパイル時間 | 2,488 ms |
コンパイル使用メモリ | 79,672 KB |
実行使用メモリ | 61,816 KB |
最終ジャッジ日時 | 2024-09-13 11:08:57 |
合計ジャッジ時間 | 10,089 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 1 TLE * 1 -- * 20 |
ソースコード
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));}}