結果

問題 No.2374 ASKT Subsequences
ユーザー ks2mks2m
提出日時 2023-07-07 21:51:47
言語 Java21
(openjdk 21)
結果
TLE  
実行時間 -
コード長 816 bytes
コンパイル時間 2,086 ms
コンパイル使用メモリ 73,592 KB
実行使用メモリ 339,612 KB
最終ジャッジ日時 2023-09-28 23:01:44
合計ジャッジ時間 38,746 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 769 ms
259,512 KB
testcase_01 AC 781 ms
257,064 KB
testcase_02 AC 767 ms
257,180 KB
testcase_03 AC 782 ms
257,200 KB
testcase_04 AC 776 ms
256,888 KB
testcase_05 AC 768 ms
257,436 KB
testcase_06 AC 768 ms
257,056 KB
testcase_07 AC 815 ms
255,152 KB
testcase_08 AC 785 ms
256,804 KB
testcase_09 AC 793 ms
257,240 KB
testcase_10 AC 847 ms
257,784 KB
testcase_11 AC 958 ms
257,680 KB
testcase_12 AC 856 ms
257,120 KB
testcase_13 AC 863 ms
257,084 KB
testcase_14 AC 961 ms
255,548 KB
testcase_15 AC 1,068 ms
257,756 KB
testcase_16 AC 931 ms
257,964 KB
testcase_17 AC 1,341 ms
257,984 KB
testcase_18 AC 1,204 ms
258,756 KB
testcase_19 AC 1,352 ms
258,120 KB
testcase_20 AC 1,398 ms
333,620 KB
testcase_21 AC 1,452 ms
335,508 KB
testcase_22 AC 1,405 ms
339,612 KB
testcase_23 TLE -
testcase_24 AC 1,615 ms
258,808 KB
testcase_25 AC 975 ms
258,024 KB
testcase_26 AC 1,949 ms
324,124 KB
testcase_27 AC 1,261 ms
323,268 KB
testcase_28 AC 1,187 ms
324,332 KB
testcase_29 AC 1,539 ms
323,248 KB
testcase_30 AC 1,153 ms
323,196 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] a = new int[n];
		for (int i = 0; i < n; i++) {
			a[i] = sc.nextInt();
		}
		sc.close();

		long[][][] dp = new long[2000][2001][4];
		for (int i = 0; i < n; i++) {
			for (int k = 1; k < 2000; k++) {
				dp[k][a[i]][0]++;
				if (a[i] - k - 10 > 0) {
					dp[k][a[i]][1] += dp[k][a[i] - k - 10][0];
				}
				if (a[i] + k <= 2000) {
					dp[k][a[i]][2] += dp[k][a[i] + k][1];
				}
				if (a[i] - k - 1 > 0) {
					dp[k][a[i]][3] += dp[k][a[i] - k - 1][2];
				}
			}
		}
		long ans = 0;
		for (int i = 0; i < dp.length; i++) {
			for (int j = 0; j < dp[i].length; j++) {
				ans += dp[i][j][3];
			}
		}
		System.out.println(ans);
	}
}
0