結果

問題 No.871 かえるのうた
コンテスト
ユーザー norioc
提出日時 2025-02-17 04:41:46
言語 PyPy3
(8.0.0 + ACL)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
WJ  
(最新)
AC  
(最初)
実行時間 -
コード長 638 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
最終ジャッジ日時 2026-10-14 01:01:52
ジャッジサーバーID
(参考情報)
judge4_0 / judge2_0
このコードへのチャレンジ
(要ログイン)

ソースコード

diff #
raw source code

from collections import deque

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

left = X[K] - A[K]
right = X[K] + A[K]
q = deque([K])
update = True
while update:
    update = False

    hd = q[0]
    if hd > 0 and left <= X[hd-1]:
        update = True
        left = min(left, X[hd-1] - A[hd-1])
        right = max(right, X[hd-1] + A[hd-1])
        q.appendleft(hd-1)

    tl = q[-1]
    if tl+1 < N and X[tl+1] <= right:
        update = True
        left = min(left, X[tl+1] - A[tl+1])
        right = max(right, X[tl+1] + A[tl+1])
        q.append(tl+1)

print(len(q))
0