結果
| 問題 | No.2374 ASKT Subsequences |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2023-07-07 23:05:22 |
| 言語 | PyPy3 (7.3.17) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 759 bytes |
| 記録 | |
| コンパイル時間 | 338 ms |
| コンパイル使用メモリ | 82,464 KB |
| 実行使用メモリ | 98,232 KB |
| 最終ジャッジ日時 | 2024-07-21 19:26:24 |
| 合計ジャッジ時間 | 5,541 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 22 TLE * 1 -- * 5 |
ソースコード
import bisect
import itertools
N = int(input())
A = list(map(int, input().split()))
D = dict()
for i in range(N):
if A[i] not in D:
D[A[i]] = [i]
else:
D[A[i]].append(i)
ans = 0
a1a3 = set()
for a1 in D.keys():
a3 = a1+10
if a3 not in D:
continue
for p in itertools.product(D[a1], D[a3]):
if p[0]>=p[1]:
continue
a1a3.add(p)
a2a4 = set()
for a2 in D.keys():
a4 = a2+1
if a4 not in D:
continue
for p in itertools.product(D[a2], D[a4]):
if p[0]>=p[1]:
continue
a2a4.add(p)
for i1, i3 in a1a3:
for i2, i4 in a2a4:
k = A[i2]-A[i1]-10
if k<=0:
continue
if i1<i2<i3<i4:
ans+=1
print(ans)