結果
| 問題 | No.871 かえるのうた |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2022-07-23 16:50:28 |
| 言語 | PyPy3 (8.0.0 + ACL) |
| 結果 |
WJ
不安定
(最新)
AC
(最初)
|
| 実行時間 | - |
| コード長 | 619 bytes |
| 記録 | |
| 最終ジャッジ日時 | 2026-10-13 23:24:05 |
|
ジャッジサーバーID (参考情報) |
judge2_0 / judge1_0 |
(要ログイン)
ソースコード
from collections import deque
import bisect
n,k = map(int,input().split())
x = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]
ans = [0]*(n)
d = deque()
d.append(k-1)
l = k-1
r = k-1
ans[k-1] = 1
while len(d):
tmp = d.popleft()
pos = x[tmp]
nl = bisect.bisect_left(x,pos-a[tmp])
nr = bisect.bisect_right(x,pos+a[tmp])
for i in range(nl,l):
if ans[i] == 1:
continue
d.append(i)
ans[i] = 1
for i in range(r,nr):
if ans[i] == 1:
continue
d.append(i)
ans[i] = 1
l = nl
r = nr
print(sum(ans))