結果
問題 |
No.2374 ASKT Subsequences
|
ユーザー |
|
提出日時 | 2023-07-07 22:10:43 |
言語 | PyPy3 (7.3.15) |
結果 |
TLE
|
実行時間 | - |
コード長 | 718 bytes |
コンパイル時間 | 276 ms |
コンパイル使用メモリ | 82,308 KB |
実行使用メモリ | 83,536 KB |
最終ジャッジ日時 | 2024-07-21 18:14:42 |
合計ジャッジ時間 | 8,070 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 24 TLE * 1 -- * 3 |
ソースコード
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)