結果

問題 No.871 かえるのうた
ユーザー 👑 Kazun
提出日時 2020-09-05 20:13:57
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 130 ms / 2,000 ms
コード長 466 bytes
コンパイル時間 196 ms
コンパイル使用メモリ 82,176 KB
実行使用メモリ 99,584 KB
最終ジャッジ日時 2024-11-30 11:03:42
合計ジャッジ時間 5,275 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 49
権限があれば一括ダウンロードができます

ソースコード

diff #

N,K=map(int,input().split())
inf=float("inf")

X=list(map(int,input().split()))
X=[-inf]+X+[inf]

A=list(map(int,input().split()))
A=[0]+A+[0]

s,t=-1,-1

p=q=K
Left =X[K]-A[K]
Right=X[K]+A[K]

while (p,q)!=(s,t):
    s,t=p,q

    if Left<=X[p-1]:
        Left =min(Left ,X[p-1]-A[p-1])
        Right=max(Right,X[p-1]+A[p-1])
        p-=1

    if X[q+1]<=Right:
        Left =min(Left ,X[q+1]-A[q+1])
        Right=max(Right,X[q+1]+A[q+1])
        q+=1

print(q-p+1)
0