結果
| 問題 |
No.2374 ASKT Subsequences
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2023-07-07 22:40:49 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 682 bytes |
| コンパイル時間 | 361 ms |
| コンパイル使用メモリ | 82,304 KB |
| 実行使用メモリ | 82,176 KB |
| 最終ジャッジ日時 | 2024-07-21 18:56:22 |
| 合計ジャッジ時間 | 8,295 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 23 TLE * 2 -- * 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 i1 in range(N):
a1 = A[i1]
a3 = a1+10
if a3 not in D:
continue
pos = bisect.bisect_left(D[a3], i1+2)
for j in range(pos, len(D[a3])):
i3 = D[a3][j]
for i2 in range(i1+1, i3):
a2 = A[i2]
k = a2-a1-10
if k<=0:
continue
a4 = a3+k+1
if a4 not in D:
continue
pos2 = bisect.bisect_left(D[a4], i3+1)
ans += len(D[a4])-pos2
print(ans)