結果

問題 No.2374 ASKT Subsequences
ユーザー tentententen
提出日時 2023-07-11 15:16:32
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 2,393 bytes
コンパイル時間 2,724 ms
コンパイル使用メモリ 82,372 KB
実行使用メモリ 63,340 KB
最終ジャッジ日時 2023-10-11 06:21:36
合計ジャッジ時間 17,471 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 86 ms
51,772 KB
testcase_01 AC 103 ms
55,528 KB
testcase_02 AC 102 ms
55,216 KB
testcase_03 AC 98 ms
55,628 KB
testcase_04 AC 105 ms
55,396 KB
testcase_05 AC 103 ms
55,336 KB
testcase_06 AC 103 ms
55,544 KB
testcase_07 AC 143 ms
55,984 KB
testcase_08 AC 121 ms
55,876 KB
testcase_09 AC 136 ms
56,024 KB
testcase_10 AC 193 ms
58,612 KB
testcase_11 AC 338 ms
60,800 KB
testcase_12 AC 262 ms
60,256 KB
testcase_13 AC 232 ms
60,124 KB
testcase_14 AC 475 ms
61,596 KB
testcase_15 AC 355 ms
61,384 KB
testcase_16 AC 439 ms
61,796 KB
testcase_17 AC 407 ms
61,440 KB
testcase_18 AC 684 ms
63,172 KB
testcase_19 AC 696 ms
62,704 KB
testcase_20 AC 754 ms
62,732 KB
testcase_21 AC 812 ms
62,676 KB
testcase_22 AC 725 ms
62,248 KB
testcase_23 AC 702 ms
62,920 KB
testcase_24 AC 687 ms
63,340 KB
testcase_25 WA -
testcase_26 AC 949 ms
62,492 KB
testcase_27 WA -
testcase_28 AC 690 ms
63,196 KB
testcase_29 AC 786 ms
61,456 KB
testcase_30 AC 631 ms
61,324 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner();
        int n = sc.nextInt();
        int[] values = new int[n];
        for (int i = 0; i < n; i++) {
            values[i] = sc.nextInt();
        }
        long ans = 0;
        for (int i = 1; i <= 2000; i++) {
            int[] add = new int[]{-i - 10, i, -i - 1};
            ArrayList<HashMap<Integer, Integer>> counts = new ArrayList<>();
            for (int j = 0; j < 4; j++) {
                counts.add(new HashMap<>());
            }
            for (int x : values) {
                for (int j = 2; j >= 0; j--) {
                    if (counts.get(j).containsKey(x + add[j])) {
                        counts.get(j + 1).put(x, counts.get(j + 1).getOrDefault(x, 0) + counts.get(j).get(x + add[j]));
                    }
                }
                counts.get(0).put(x, counts.get(0).getOrDefault(x, 0) + 1);
            }
            for (int x : counts.get(3).values()) {
                ans += x;
            }
        }
        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