結果

問題 No.2374 ASKT Subsequences
ユーザー hibit_at
提出日時 2023-06-16 20:53:30
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,657 ms / 2,000 ms
コード長 460 bytes
コンパイル時間 145 ms
コンパイル使用メモリ 82,020 KB
実行使用メモリ 98,400 KB
最終ジャッジ日時 2024-06-29 22:37:20
合計ジャッジ時間 16,290 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 28
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import defaultdict

n = int(input())
a = list(map(int, input().split(' ')))

ans = 0

for d in range(1, 2000):
    mp = defaultdict(int)
    for i in range(n):
        mp[(a[i], 0)] += 1
        if (a[i] - 10 - d, 0) in mp:
            mp[(a[i], 1)] += mp[(a[i] - 10 - d, 0)]
        if (a[i] + d, 1) in mp:
            mp[(a[i], 2)] += mp[(a[i] + d, 1)]
        if (a[i] - d - 1, 2) in mp:
            ans += mp[(a[i] - d - 1, 2)]
print(ans)
0