結果
問題 | No.189 SUPER HAPPY DAY |
ユーザー | tenten |
提出日時 | 2021-11-10 16:57:30 |
言語 | Java21 (openjdk 21) |
結果 |
WA
|
実行時間 | - |
コード長 | 2,414 bytes |
コンパイル時間 | 3,758 ms |
コンパイル使用メモリ | 79,288 KB |
実行使用メモリ | 55,792 KB |
最終ジャッジ日時 | 2024-11-21 05:38:53 |
合計ジャッジ時間 | 9,792 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 52 ms
46,380 KB |
testcase_01 | AC | 66 ms
46,520 KB |
testcase_02 | AC | 54 ms
46,288 KB |
testcase_03 | AC | 58 ms
46,232 KB |
testcase_04 | AC | 59 ms
46,132 KB |
testcase_05 | AC | 59 ms
46,464 KB |
testcase_06 | AC | 57 ms
46,304 KB |
testcase_07 | AC | 60 ms
46,424 KB |
testcase_08 | AC | 58 ms
45,876 KB |
testcase_09 | AC | 61 ms
46,004 KB |
testcase_10 | AC | 58 ms
46,268 KB |
testcase_11 | AC | 58 ms
46,220 KB |
testcase_12 | AC | 60 ms
46,376 KB |
testcase_13 | WA | - |
testcase_14 | WA | - |
testcase_15 | WA | - |
testcase_16 | WA | - |
testcase_17 | WA | - |
testcase_18 | WA | - |
testcase_19 | WA | - |
testcase_20 | WA | - |
testcase_21 | WA | - |
testcase_22 | WA | - |
testcase_23 | AC | 419 ms
53,020 KB |
testcase_24 | AC | 418 ms
53,204 KB |
testcase_25 | WA | - |
ソースコード
import java.util.*; import java.io.*; public class Main { static final int MOD = 1000000009; public static void main(String[] args) throws Exception { Scanner sc = new Scanner(); TreeMap<Integer, Long> month = getCount(sc.next().toCharArray()); TreeMap<Integer, Long> day = getCount(sc.next().toCharArray()); long ans = 0; for (int x : month.keySet()) { if (x == 0) { continue; } ans += month.get(x) * day.getOrDefault(x, 0L) % MOD; ans %= MOD; } System.out.println(ans); } static TreeMap<Integer, Long> getCount(char[] value) { TreeMap<Integer, Long> counts = new TreeMap<>(); counts.put(0, 1L); int total = 0; boolean isFirst = true; for (char c : value) { int x = c - '0'; if (isFirst) { isFirst = false; for (int i = 1; i < x; i++) { counts.put(i, 1L); } total += x; continue; } Integer key = Integer.MAX_VALUE; while ((key = counts.lowerKey(key)) != null) { for (int i = 1; i <= 9; i++) { counts.put(key + i, counts.getOrDefault(key + i, 0L) + counts.get(key)); } } for (int i = 0; i < x; i++) { counts.put(total + i, counts.getOrDefault(total + i, 0L) + 1); } total += x; } counts.put(total, counts.getOrDefault(total, 0L) + 1); return counts; } } class Scanner { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer st = new StringTokenizer(""); public Scanner() throws Exception { } public int nextInt() throws Exception { return Integer.parseInt(next()); } public long nextLong() throws Exception { return Long.parseLong(next()); } public double nextDouble() throws Exception { return Double.parseDouble(next()); } public String nextLine() throws Exception { return br.readLine(); } public String next() throws Exception { if (!st.hasMoreTokens()) { st = new StringTokenizer(br.readLine()); } return st.nextToken(); } }