結果

問題 No.2374 ASKT Subsequences
ユーザー hibit_athibit_at
提出日時 2023-06-16 20:53:30
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,729 ms / 2,000 ms
コード長 460 bytes
コンパイル時間 273 ms
コンパイル使用メモリ 87,284 KB
実行使用メモリ 100,060 KB
最終ジャッジ日時 2023-09-12 09:57:00
合計ジャッジ時間 18,844 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 107 ms
77,840 KB
testcase_01 AC 114 ms
78,032 KB
testcase_02 AC 108 ms
77,900 KB
testcase_03 AC 115 ms
77,940 KB
testcase_04 AC 131 ms
78,588 KB
testcase_05 AC 113 ms
77,984 KB
testcase_06 AC 114 ms
77,936 KB
testcase_07 AC 148 ms
78,564 KB
testcase_08 AC 140 ms
78,412 KB
testcase_09 AC 145 ms
78,572 KB
testcase_10 AC 170 ms
78,752 KB
testcase_11 AC 295 ms
79,036 KB
testcase_12 AC 219 ms
79,092 KB
testcase_13 AC 209 ms
79,244 KB
testcase_14 AC 367 ms
79,900 KB
testcase_15 AC 443 ms
80,112 KB
testcase_16 AC 320 ms
79,368 KB
testcase_17 AC 544 ms
79,348 KB
testcase_18 AC 794 ms
81,056 KB
testcase_19 AC 738 ms
80,284 KB
testcase_20 AC 1,030 ms
83,936 KB
testcase_21 AC 1,158 ms
84,712 KB
testcase_22 AC 937 ms
83,596 KB
testcase_23 AC 806 ms
80,656 KB
testcase_24 AC 805 ms
80,524 KB
testcase_25 AC 505 ms
78,588 KB
testcase_26 AC 1,551 ms
88,184 KB
testcase_27 AC 865 ms
78,704 KB
testcase_28 AC 1,099 ms
79,368 KB
testcase_29 AC 1,729 ms
100,060 KB
testcase_30 AC 1,191 ms
81,280 KB
権限があれば一括ダウンロードができます

ソースコード

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