結果

問題 No.871 かえるのうた
ユーザー takakin
提出日時 2020-06-25 23:29:22
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 268 ms / 2,000 ms
コード長 444 bytes
コンパイル時間 252 ms
コンパイル使用メモリ 12,800 KB
実行使用メモリ 28,060 KB
最終ジャッジ日時 2024-11-30 11:02:04
合計ジャッジ時間 5,638 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 49
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input=lambda: sys.stdin.readline().rstrip()
n,k=map(int,input().split())
X=[int(i) for i in input().split()]
A=[int(i) for i in input().split()]
l,r=X[k-1]-A[k-1],X[k-1]+A[k-1]
ll,rr=k-1,k-1
while True:
  if ll-1>=0 and X[ll-1]>=l:
    l=min(l,X[ll-1]-A[ll-1])
    r=max(r,X[ll-1]+A[ll-1])
    ll-=1
  elif rr+1<n and X[rr+1]<=r:
    r=max(r,X[rr+1]+A[rr+1])
    l=min(l,X[rr+1]-A[rr+1])
    rr+=1 
  else:
    break
print(rr-ll+1)

0