結果

問題 No.871 かえるのうた
ユーザー ああいい
提出日時 2022-04-19 18:47:04
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 439 bytes
コンパイル時間 297 ms
コンパイル使用メモリ 82,884 KB
実行使用メモリ 99,052 KB
最終ジャッジ日時 2025-01-02 09:48:12
合計ジャッジ時間 4,657 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 43 WA * 6
権限があれば一括ダウンロードができます

ソースコード

diff #

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

migi = X[K] + A[K]
hidari = X[K] - A[K]
stack = [(K,1),(K,-1)]
ans = 1
while stack:
    now,d = stack.pop()
    if 0 <= now + d < N and hidari <= X[now + d] <= migi:
        migi = max(migi,X[now + d] + A[now + d])
        hidari = min(hidari,X[now + d] - A[now + d])
        stack.append((now + d,d))
        ans += 1
print(ans)
0