結果

問題 No.2055 12x34...
ユーザー tentententen
提出日時 2023-07-25 08:51:53
言語 Java21
(openjdk 21)
結果
AC  
実行時間 444 ms / 2,000 ms
コード長 1,829 bytes
コンパイル時間 2,846 ms
コンパイル使用メモリ 85,252 KB
実行使用メモリ 75,596 KB
最終ジャッジ日時 2024-04-10 02:09:01
合計ジャッジ時間 16,500 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 50 ms
50,324 KB
testcase_01 AC 51 ms
50,460 KB
testcase_02 AC 163 ms
55,284 KB
testcase_03 AC 224 ms
56,508 KB
testcase_04 AC 244 ms
56,424 KB
testcase_05 AC 247 ms
56,368 KB
testcase_06 AC 239 ms
56,384 KB
testcase_07 AC 230 ms
56,508 KB
testcase_08 AC 214 ms
56,272 KB
testcase_09 AC 248 ms
56,336 KB
testcase_10 AC 263 ms
55,896 KB
testcase_11 AC 194 ms
55,812 KB
testcase_12 AC 344 ms
63,044 KB
testcase_13 AC 443 ms
67,888 KB
testcase_14 AC 274 ms
58,812 KB
testcase_15 AC 295 ms
58,724 KB
testcase_16 AC 444 ms
67,652 KB
testcase_17 AC 276 ms
58,736 KB
testcase_18 AC 324 ms
62,896 KB
testcase_19 AC 196 ms
56,016 KB
testcase_20 AC 138 ms
54,528 KB
testcase_21 AC 201 ms
56,156 KB
testcase_22 AC 358 ms
65,384 KB
testcase_23 AC 366 ms
69,168 KB
testcase_24 AC 399 ms
74,040 KB
testcase_25 AC 371 ms
71,816 KB
testcase_26 AC 377 ms
72,312 KB
testcase_27 AC 400 ms
74,184 KB
testcase_28 AC 366 ms
72,364 KB
testcase_29 AC 377 ms
75,596 KB
testcase_30 AC 359 ms
72,288 KB
testcase_31 AC 368 ms
69,900 KB
testcase_32 AC 375 ms
71,984 KB
testcase_33 AC 307 ms
56,284 KB
testcase_34 AC 305 ms
56,108 KB
testcase_35 AC 304 ms
56,200 KB
testcase_36 AC 293 ms
56,392 KB
testcase_37 AC 305 ms
56,108 KB
testcase_38 AC 306 ms
56,156 KB
testcase_39 AC 305 ms
55,988 KB
testcase_40 AC 311 ms
56,220 KB
testcase_41 AC 283 ms
56,100 KB
testcase_42 AC 305 ms
56,252 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.*;
import java.util.*;
import java.util.stream.*;

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, Long> prev = new HashMap<>();
        long ans = 0;
        while (n-- > 0) {
            int x = sc.nextInt();
            ans += prev.getOrDefault(x - 1, 0L);
            ans %= MOD;
            prev.put(x, (prev.getOrDefault(x, 0L) + prev.getOrDefault(x - 1, 0L) + 1) % MOD);
        }
        System.out.println(ans);
    }
}
class Utilities {
    static String arrayToLineString(Object[] arr) {
        return Arrays.stream(arr).map(x -> x.toString()).collect(Collectors.joining("\n"));
    }
    
    static String arrayToLineString(int[] arr) {
        return String.join("\n", Arrays.stream(arr).mapToObj(String::valueOf).toArray(String[]::new));
    }
}
class Scanner {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    StringTokenizer st = new StringTokenizer("");
    StringBuilder sb = new StringBuilder();
    
    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 int[] nextIntArray() throws Exception {
        return Stream.of(br.readLine().split(" ")).mapToInt(Integer::parseInt).toArray();
    }
    
    public String next() throws Exception {
        while (!st.hasMoreTokens()) {
            st = new StringTokenizer(br.readLine());
        }
        return st.nextToken();
    }
    
}
0