結果

問題 No.871 かえるのうた
コンテスト
ユーザー norioc
提出日時 2025-02-17 04:41:46
言語 PyPy3
(7.3.17)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
AC  
実行時間 89 ms / 2,000 ms
コード長 638 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 1,634 ms
コンパイル使用メモリ 85,120 KB
実行使用メモリ 108,288 KB
最終ジャッジ日時 2026-07-02 14:09:23
合計ジャッジ時間 5,693 ms
ジャッジサーバーID
(参考情報)
judge2_0 / judge1_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 49
権限があれば一括ダウンロードができます

ソースコード

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