結果
問題 | No.1238 選抜クラス |
ユーザー | tenten |
提出日時 | 2020-09-28 11:49:54 |
言語 | Java21 (openjdk 21) |
結果 |
AC
|
実行時間 | 365 ms / 2,000 ms |
コード長 | 1,296 bytes |
コンパイル時間 | 2,683 ms |
コンパイル使用メモリ | 81,032 KB |
実行使用メモリ | 63,308 KB |
最終ジャッジ日時 | 2023-09-14 13:28:36 |
合計ジャッジ時間 | 11,750 ms |
ジャッジサーバーID (参考情報) |
judge13 / judge15 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 128 ms
57,676 KB |
testcase_01 | AC | 126 ms
55,984 KB |
testcase_02 | AC | 130 ms
56,184 KB |
testcase_03 | AC | 125 ms
55,936 KB |
testcase_04 | AC | 125 ms
55,736 KB |
testcase_05 | AC | 123 ms
55,668 KB |
testcase_06 | AC | 125 ms
55,860 KB |
testcase_07 | AC | 126 ms
55,516 KB |
testcase_08 | AC | 132 ms
55,532 KB |
testcase_09 | AC | 146 ms
55,984 KB |
testcase_10 | AC | 125 ms
55,796 KB |
testcase_11 | AC | 133 ms
56,088 KB |
testcase_12 | AC | 132 ms
55,704 KB |
testcase_13 | AC | 137 ms
55,616 KB |
testcase_14 | AC | 129 ms
55,868 KB |
testcase_15 | AC | 140 ms
55,772 KB |
testcase_16 | AC | 141 ms
53,740 KB |
testcase_17 | AC | 323 ms
62,928 KB |
testcase_18 | AC | 303 ms
62,916 KB |
testcase_19 | AC | 323 ms
61,084 KB |
testcase_20 | AC | 365 ms
63,292 KB |
testcase_21 | AC | 327 ms
62,956 KB |
testcase_22 | AC | 133 ms
55,780 KB |
testcase_23 | AC | 151 ms
55,824 KB |
testcase_24 | AC | 152 ms
58,064 KB |
testcase_25 | AC | 135 ms
56,016 KB |
testcase_26 | AC | 278 ms
58,972 KB |
testcase_27 | AC | 344 ms
60,684 KB |
testcase_28 | AC | 311 ms
63,308 KB |
testcase_29 | AC | 299 ms
62,956 KB |
testcase_30 | AC | 160 ms
55,640 KB |
testcase_31 | AC | 190 ms
58,036 KB |
testcase_32 | AC | 314 ms
62,876 KB |
testcase_33 | AC | 126 ms
55,932 KB |
testcase_34 | AC | 222 ms
58,736 KB |
testcase_35 | AC | 171 ms
55,740 KB |
testcase_36 | AC | 150 ms
55,620 KB |
testcase_37 | AC | 169 ms
55,784 KB |
testcase_38 | AC | 305 ms
62,904 KB |
ソースコード
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 k = sc.nextInt(); TreeMap<Integer, Integer> map = new TreeMap<>(); map.put(0, 1); for (int i = 0; i < n; i++) { int x = sc.nextInt() - k; if (x >= 0) { Integer key = Integer.MAX_VALUE; while ((key = map.lowerKey(key)) != null) { int next = key + x; if (map.containsKey(next)) { map.put(next, (map.get(next) + map.get(key)) % MOD); } else { map.put(next, map.get(key)); } } } else { Integer key = Integer.MIN_VALUE; while ((key = map.higherKey(key)) != null) { int next = key + x; if (map.containsKey(next)) { map.put(next, (map.get(next) + map.get(key)) % MOD); } else { map.put(next, map.get(key)); } } } } int total = - 1; for (Map.Entry<Integer, Integer> entry : map.entrySet()) { if (entry.getKey() >= 0) { total += entry.getValue(); total %= MOD; } } System.out.println(total); } }