結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 74 ms
51,900 KB
testcase_01 AC 101 ms
55,512 KB
testcase_02 AC 93 ms
55,284 KB
testcase_03 AC 99 ms
55,012 KB
testcase_04 AC 105 ms
55,420 KB
testcase_05 AC 101 ms
55,004 KB
testcase_06 AC 97 ms
55,344 KB
testcase_07 AC 141 ms
55,664 KB
testcase_08 AC 123 ms
53,472 KB
testcase_09 AC 144 ms
56,200 KB
testcase_10 AC 191 ms
58,240 KB
testcase_11 AC 323 ms
61,644 KB
testcase_12 AC 261 ms
60,524 KB
testcase_13 AC 234 ms
60,192 KB
testcase_14 AC 435 ms
62,024 KB
testcase_15 AC 380 ms
61,184 KB
testcase_16 AC 310 ms
61,228 KB
testcase_17 AC 407 ms
61,280 KB
testcase_18 AC 694 ms
63,048 KB
testcase_19 AC 693 ms
63,372 KB
testcase_20 AC 758 ms
62,584 KB
testcase_21 AC 907 ms
62,760 KB
testcase_22 AC 806 ms
62,796 KB
testcase_23 AC 595 ms
62,432 KB
testcase_24 AC 630 ms
63,144 KB
testcase_25 AC 305 ms
57,616 KB
testcase_26 AC 946 ms
62,736 KB
testcase_27 AC 425 ms
58,744 KB
testcase_28 AC 577 ms
60,644 KB
testcase_29 AC 773 ms
61,300 KB
testcase_30 AC 621 ms
61,784 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, Long>> 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, 0L) + counts.get(j).get(x + add[j]));
                    }
                }
                counts.get(0).put(x, counts.get(0).getOrDefault(x, 0L) + 1);
            }
            for (long 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