結果

問題 No.2374 ASKT Subsequences
ユーザー miya145592miya145592
提出日時 2023-07-07 22:10:43
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 718 bytes
コンパイル時間 551 ms
コンパイル使用メモリ 86,984 KB
実行使用メモリ 82,028 KB
最終ジャッジ日時 2023-09-28 23:31:02
合計ジャッジ時間 10,369 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 75 ms
71,268 KB
testcase_01 AC 76 ms
71,116 KB
testcase_02 AC 76 ms
71,100 KB
testcase_03 AC 76 ms
71,380 KB
testcase_04 AC 77 ms
71,468 KB
testcase_05 AC 77 ms
71,308 KB
testcase_06 AC 76 ms
71,380 KB
testcase_07 AC 75 ms
71,096 KB
testcase_08 AC 75 ms
71,368 KB
testcase_09 AC 76 ms
71,532 KB
testcase_10 AC 87 ms
75,884 KB
testcase_11 AC 106 ms
77,168 KB
testcase_12 AC 93 ms
76,708 KB
testcase_13 AC 90 ms
76,396 KB
testcase_14 AC 125 ms
77,464 KB
testcase_15 AC 147 ms
77,948 KB
testcase_16 AC 114 ms
77,404 KB
testcase_17 AC 132 ms
77,592 KB
testcase_18 AC 162 ms
77,548 KB
testcase_19 AC 154 ms
77,796 KB
testcase_20 AC 188 ms
77,884 KB
testcase_21 AC 205 ms
78,152 KB
testcase_22 AC 185 ms
78,572 KB
testcase_23 AC 171 ms
78,276 KB
testcase_24 AC 162 ms
77,808 KB
testcase_25 AC 1,986 ms
77,908 KB
testcase_26 AC 296 ms
78,584 KB
testcase_27 TLE -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

import bisect

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

D = dict()
for i in range(1, N):
    if A[i] not in D:
        D[A[i]] = [i]
    else:
        D[A[i]].append(i)

ans = 0
for i2 in range(1, N):
    a2 = A[i2]
    for i1 in range(i2):
        a1 = A[i1]
        k = a2-a1-10
        if k<=0:
            continue
        
        a3 = a2-k
        if a3 not in D:
            continue
        pos = bisect.bisect_left(D[a3], i2+1)
        if pos==N:
            continue
        a4 = a3+k+1
        if a4 not in D:
            continue
        for j in range(pos, len(D[a3])):
            i3 = D[a3][j]
            pos2 = bisect.bisect_left(D[a4], i3+1)
            ans += len(D[a4])-pos2
print(ans)
0