結果

問題 No.2055 12x34...
ユーザー tentententen
提出日時 2023-01-19 18:35:16
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 1,990 bytes
コンパイル時間 5,147 ms
コンパイル使用メモリ 82,004 KB
実行使用メモリ 75,052 KB
最終ジャッジ日時 2023-09-04 07:55:36
合計ジャッジ時間 20,294 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 44 ms
49,740 KB
testcase_01 AC 44 ms
49,424 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 340 ms
62,364 KB
testcase_13 AC 441 ms
66,688 KB
testcase_14 AC 280 ms
58,580 KB
testcase_15 AC 272 ms
58,752 KB
testcase_16 AC 447 ms
66,504 KB
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 380 ms
70,556 KB
testcase_24 AC 375 ms
73,440 KB
testcase_25 AC 369 ms
69,952 KB
testcase_26 AC 372 ms
70,676 KB
testcase_27 AC 411 ms
75,052 KB
testcase_28 AC 357 ms
73,044 KB
testcase_29 AC 376 ms
73,216 KB
testcase_30 AC 377 ms
70,940 KB
testcase_31 AC 388 ms
70,980 KB
testcase_32 AC 392 ms
72,836 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 -
権限があれば一括ダウンロードができます

ソースコード

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> lengths = new HashMap<>();
        long ans = 0;
        for (int i = 0; i < n; i++) {
            int x = sc.nextInt();
            if (lengths.containsKey(x - 1)) {
                lengths.put(x, lengths.getOrDefault(x, 0L) + lengths.get(x - 1) + 1);
                ans += lengths.get(x - 1);
                ans %= MOD;
            } else {
                lengths.put(x, lengths.getOrDefault(x, 0L) + 1);
            }
        }
        
        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