結果

問題 No.3456 Common Difference is D
コンテスト
ユーザー はくさいぶちょう
提出日時 2026-04-28 17:52:18
言語 Python3
(3.14.3 + numpy 2.4.4 + scipy 1.17.1)
コンパイル:
python3 -mpy_compile _filename_
実行:
python3 _filename_
結果
TLE  
実行時間 -
コード長 658 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 332 ms
コンパイル使用メモリ 20,572 KB
実行使用メモリ 25,324 KB
最終ジャッジ日時 2026-04-28 17:52:41
合計ジャッジ時間 5,083 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge2_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 5 TLE * 1 -- * 14
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

N, D = map(int, input().split())
A :list[int]= list(map(int, input().split()))
res=0
mag=0
for i in range(N-2):
    n=len(A)-1
    mag+=1
    base=A.pop(0)
    if A[0]==base:
        continue
    if not base+D in A:
        mag=0
        continue
    start=A.index(base+D)
    j=0
    if start>n-2:
        mag=0
        continue
    while A[start+j]==base+D:
        j+=1
        if start+j>n-1:
            break
    mag*=j
    if not base+D*2 in A[start:]:
        mag=0
        continue
    j=0
    start=A.index(base+D*2)
    while A[start+j]==base+D*2:
        j+=1
        if start+j>n-1:
            break
    mag*=j
    res+=mag
    mag=0
print(res)
0