結果

問題 No.871 かえるのうた
ユーザー None
提出日時 2021-03-12 14:04:06
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 110 ms / 2,000 ms
コード長 387 bytes
コンパイル時間 203 ms
コンパイル使用メモリ 82,540 KB
実行使用メモリ 98,512 KB
最終ジャッジ日時 2024-11-30 11:05:11
合計ジャッジ時間 4,745 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 49
権限があれば一括ダウンロードができます

ソースコード

diff #

N,K=map(int, input().split())
X=list(map(int, input().split()))
A=list(map(int, input().split()))

l,r=K-1,K-1
L,R=X[l]-A[l],X[r]+A[r]
while (r+1<N and X[r+1]<=R) or (l>0 and X[l-1]>=L):
    if r+1<N and X[r+1]<=R:
        r+=1
        R=max(X[r]+A[r],R)
        L=min(X[r]-A[r],L)
    if l>0 and X[l-1]>=L:
        l-=1
        R=max(X[l]+A[l],R)
        L=min(X[l]-A[l],L)
print(r-l+1)
0