結果

問題 No.3392 Count 23578 Sequence
コンテスト
ユーザー ああ
提出日時 2026-05-23 15:20:28
言語 PyPy3
(7.3.17)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
AC  
実行時間 364 ms / 2,000 ms
コード長 511 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 275 ms
コンパイル使用メモリ 85,120 KB
実行使用メモリ 320,392 KB
最終ジャッジ日時 2026-05-23 15:20:58
合計ジャッジ時間 26,769 ms
ジャッジサーバーID
(参考情報)
judge3_1 / judge2_1
純コード判定待ち
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 48
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

def manacher(x):
    n=len(x)
    res=[0]*n
    i,j=0,0
    while i<n:
        while i-j>=0 and i+j<n and x[i-j]==x[i+j]:
            j+=1
        res[i]=j;k=1
        while i-k>=0 and k+res[i-k]<j:
            res[i+k]=res[i-k];k+=1
        i+=k;j-=k
    return res

n=int(input());ans=n
a=list(map(int,input().split()))
x=[]
for i in range(1,n):
    x.append(a[i]-a[i-1]);x.append(1<<60)
x=manacher(x[:-1])
for i in range(len(x)):
    if i&1:
        ans+=x[i]//2
    else:
        ans+=(x[i]+1)//2
print(ans)
0