結果
| 問題 | No.871 かえるのうた | 
| コンテスト | |
| ユーザー |  toyuzuko | 
| 提出日時 | 2020-05-09 09:52:37 | 
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 246 ms / 2,000 ms | 
| コード長 | 593 bytes | 
| コンパイル時間 | 96 ms | 
| コンパイル使用メモリ | 12,800 KB | 
| 実行使用メモリ | 28,124 KB | 
| 最終ジャッジ日時 | 2024-11-30 11:01:40 | 
| 合計ジャッジ時間 | 5,125 ms | 
| ジャッジサーバーID (参考情報) | judge4 / judge3 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| other | AC * 49 | 
ソースコード
N, K = map(int, input().split())
X = list(map(int, input().split()))
A = list(map(int, input().split()))
lt = X[K - 1] - A[K - 1]
rt = X[K - 1] + A[K - 1]
lidx = K - 1
ridx = K - 1
while True:
    update = False
    if lidx > 0 and X[lidx - 1] >= lt:
        lidx -= 1
        lt = min(lt, X[lidx] - A[lidx])
        rt = max(rt, X[lidx] + A[lidx])
        update = True
    if ridx < N - 1 and X[ridx + 1] <= rt:
        ridx += 1
        lt = min(lt, X[ridx] - A[ridx])
        rt = max(rt, X[ridx] + A[ridx])
        update = True
    if not update:
        break
print(ridx - lidx + 1)
            
            
            
        