結果

問題 No.2374 ASKT Subsequences
ユーザー titiatitia
提出日時 2023-07-11 02:54:17
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 520 ms / 2,000 ms
コード長 683 bytes
コンパイル時間 693 ms
コンパイル使用メモリ 86,912 KB
実行使用メモリ 86,224 KB
最終ジャッジ日時 2023-10-10 01:29:59
合計ジャッジ時間 8,920 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 87 ms
76,640 KB
testcase_01 AC 87 ms
76,296 KB
testcase_02 AC 88 ms
76,504 KB
testcase_03 AC 89 ms
76,484 KB
testcase_04 AC 94 ms
76,592 KB
testcase_05 AC 89 ms
76,304 KB
testcase_06 AC 90 ms
76,456 KB
testcase_07 AC 114 ms
77,360 KB
testcase_08 AC 105 ms
77,024 KB
testcase_09 AC 110 ms
77,284 KB
testcase_10 AC 118 ms
77,324 KB
testcase_11 AC 189 ms
78,692 KB
testcase_12 AC 159 ms
77,816 KB
testcase_13 AC 138 ms
77,628 KB
testcase_14 AC 195 ms
78,504 KB
testcase_15 AC 215 ms
78,412 KB
testcase_16 AC 200 ms
78,604 KB
testcase_17 AC 214 ms
78,752 KB
testcase_18 AC 286 ms
79,748 KB
testcase_19 AC 258 ms
79,016 KB
testcase_20 AC 443 ms
82,608 KB
testcase_21 AC 396 ms
82,540 KB
testcase_22 AC 471 ms
82,724 KB
testcase_23 AC 281 ms
80,000 KB
testcase_24 AC 290 ms
79,556 KB
testcase_25 AC 208 ms
79,312 KB
testcase_26 AC 520 ms
84,656 KB
testcase_27 AC 236 ms
83,472 KB
testcase_28 AC 342 ms
86,224 KB
testcase_29 AC 279 ms
83,928 KB
testcase_30 AC 350 ms
86,200 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N=int(input())
A=list(map(int,input().split()))

LIST=[[] for i in range(2001)]

for i in range(N):
    LIST[A[i]].append(i)

ANS=0

for k in range(1,2001):
    DP=[[0,0,0] for i in range(N)]
    for i in range(N):
        a=A[i]

        if 1<=a+k+10<=2000:
            for j in LIST[a+k+10]:
                if j>i:
                    DP[j][1]+=1

        if 1<=a-k<=2000:
            if DP[i][1]!=0:
                for j in LIST[a-k]:
                    if j>i:
                        DP[j][2]+=DP[i][1]

        if 1<=a+k+1<=2000:
            if DP[i][2]!=0:
                for j in LIST[a+k+1]:
                    if j>i:
                        ANS+=DP[i][2]

print(ANS)
0