結果

問題 No.2374 ASKT Subsequences
ユーザー ryohei22ryohei22
提出日時 2023-07-08 13:17:44
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 640 ms / 2,000 ms
コード長 533 bytes
コンパイル時間 788 ms
コンパイル使用メモリ 87,088 KB
実行使用メモリ 177,120 KB
最終ジャッジ日時 2023-09-29 14:36:18
合計ジャッジ時間 7,645 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 95 ms
71,604 KB
testcase_01 AC 91 ms
71,408 KB
testcase_02 AC 91 ms
71,724 KB
testcase_03 AC 94 ms
71,720 KB
testcase_04 AC 92 ms
71,608 KB
testcase_05 AC 92 ms
71,660 KB
testcase_06 AC 93 ms
71,660 KB
testcase_07 AC 95 ms
71,844 KB
testcase_08 AC 92 ms
71,748 KB
testcase_09 AC 94 ms
71,692 KB
testcase_10 AC 116 ms
77,992 KB
testcase_11 AC 127 ms
78,456 KB
testcase_12 AC 111 ms
78,028 KB
testcase_13 AC 109 ms
77,900 KB
testcase_14 AC 127 ms
78,280 KB
testcase_15 AC 129 ms
78,196 KB
testcase_16 AC 116 ms
78,472 KB
testcase_17 AC 146 ms
83,688 KB
testcase_18 AC 195 ms
96,008 KB
testcase_19 AC 191 ms
93,228 KB
testcase_20 AC 328 ms
129,188 KB
testcase_21 AC 384 ms
147,196 KB
testcase_22 AC 273 ms
114,528 KB
testcase_23 AC 195 ms
96,124 KB
testcase_24 AC 204 ms
95,992 KB
testcase_25 AC 118 ms
77,604 KB
testcase_26 AC 640 ms
177,120 KB
testcase_27 AC 134 ms
78,300 KB
testcase_28 AC 189 ms
78,456 KB
testcase_29 AC 166 ms
119,908 KB
testcase_30 AC 193 ms
92,168 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import defaultdict


"""
解説AC
	reference: https://www.youtube.com/watch?v=ImVYMpTuXiY

[方針]
a2 と a3 を固定する。
"""
N = int(input())
A = list(map(int, input().split()))

# s[i][j]: s[0]-s[i] に含まれる j の個数
s = []
cnt = defaultdict(int)
for i in A:
	cnt[i] += 1
	s.append(cnt.copy())

ans = 0
for i in range(1, N-2):
	a2 = A[i]
	for j in range(i+1, N-1):
		a3 = A[j]
		k = a2 - a3
		a1 = a2 - k - 10
		a4 = a3 + k + 1
		if 0 < k:
			ans += s[i-1][a1] * (s[-1][a4] - s[j][a4])
print(ans)
0