結果
問題 | No.2055 12x34... |
ユーザー | tenten |
提出日時 | 2022-08-22 13:04:51 |
言語 | Java21 (openjdk 21) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,392 bytes |
コンパイル時間 | 2,320 ms |
コンパイル使用メモリ | 78,652 KB |
実行使用メモリ | 67,048 KB |
最終ジャッジ日時 | 2024-04-18 13:22:54 |
合計ジャッジ時間 | 16,000 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 53 ms
37,056 KB |
testcase_01 | AC | 55 ms
37,040 KB |
testcase_02 | WA | - |
testcase_03 | WA | - |
testcase_04 | WA | - |
testcase_05 | WA | - |
testcase_06 | WA | - |
testcase_07 | WA | - |
testcase_08 | WA | - |
testcase_09 | WA | - |
testcase_10 | WA | - |
testcase_11 | WA | - |
testcase_12 | AC | 303 ms
50,948 KB |
testcase_13 | AC | 386 ms
57,640 KB |
testcase_14 | AC | 229 ms
49,624 KB |
testcase_15 | AC | 242 ms
48,816 KB |
testcase_16 | AC | 401 ms
58,168 KB |
testcase_17 | WA | - |
testcase_18 | WA | - |
testcase_19 | WA | - |
testcase_20 | WA | - |
testcase_21 | WA | - |
testcase_22 | WA | - |
testcase_23 | AC | 375 ms
55,444 KB |
testcase_24 | AC | 378 ms
61,140 KB |
testcase_25 | AC | 368 ms
57,456 KB |
testcase_26 | AC | 353 ms
57,988 KB |
testcase_27 | AC | 373 ms
61,720 KB |
testcase_28 | AC | 400 ms
60,396 KB |
testcase_29 | AC | 371 ms
60,508 KB |
testcase_30 | AC | 357 ms
59,976 KB |
testcase_31 | AC | 373 ms
59,036 KB |
testcase_32 | AC | 366 ms
60,232 KB |
testcase_33 | WA | - |
testcase_34 | WA | - |
testcase_35 | WA | - |
testcase_36 | WA | - |
testcase_37 | WA | - |
testcase_38 | WA | - |
testcase_39 | WA | - |
testcase_40 | WA | - |
testcase_41 | WA | - |
testcase_42 | WA | - |
ソースコード
import java.io.*; import java.util.*; public class Main { static final int MOD = 998244353; public static void main(String[] args) throws Exception { Scanner sc = new Scanner(); int n = sc.nextInt(); HashMap<Integer, Integer> counts = new HashMap<>(); int ans = 0; for (int i = 0; i < n; i++) { int x = sc.nextInt(); if (counts.containsKey(x - 1)) { ans += counts.get(x - 1); ans %= MOD; counts.put(x, (counts.getOrDefault(x, 0) + counts.get(x - 1) + 1) % MOD); } else { counts.put(x, 1); } } System.out.println(ans); } } 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 next() throws Exception { while (!st.hasMoreTokens()) { st = new StringTokenizer(br.readLine()); } return st.nextToken(); } }