結果

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

ソースコード

diff #

n,k=map(int,input().split())
x=list(map(int,input().split()))
a=list(map(int,input().split()))
k-=1
l=r=k
ld=x[k]-a[k]
rd=x[k]+a[k]
f=True
while f:
 f=False
 while l-1>=0 and ld<=x[l-1]:
  f=True
  l-=1
  ld=min(ld,x[l]-a[l])
  rd=max(rd,x[l]+a[l])
 while r+1<n and rd>=x[r+1]:
  f=True
  r+=1
  ld=min(ld,x[r]-a[r])
  rd=max(rd,x[r]+a[r])
print(r-l+1)
0