結果

問題 No.871 かえるのうた
コンテスト
ユーザー tktk_snsn
提出日時 2021-02-07 19:37:09
言語 PyPy3
(8.0.0 + ACL)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
AC  
実行時間 87 ms / 2,000 ms
+ 373µs
コード長 550 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 88 ms
コンパイル使用メモリ 64,800 KB
実行使用メモリ 92,556 KB
最終ジャッジ日時 2026-10-19 22:26:17
合計ジャッジ時間 6,736 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge6_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 51
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

N, K = map(int, input().split())
inf = float("inf")
X = [-inf] + list(map(int, input().split())) + [inf]
A = [-1] + list(map(int, input().split())) + [inf]

ans = [0] * (N + 2)

# left
L = X[K]
R = X[K]
i = K
j = K
while i or j < N + 1:
    if i and X[i] >= L:
        ans[i] = 1
        L = min(L, X[i] - A[i])
        R = max(R, X[i] + A[i])
        i -= 1
        continue
    if j < N + 1 and X[j] <= R:
        ans[j] = 1
        L = min(L, X[j] - A[j])
        R = max(R, X[j] + A[j])
        j += 1
        continue
    break


print(sum(ans))
0