結果

問題 No.871 かえるのうた
コンテスト
ユーザー Mine
提出日時 2020-09-06 23:15:08
言語 Python3
(3.15.0 + numpy 2.5.4 + scipy 1.18.1 + ACL)
コンパイル:
python3 -mpy_compile _filename_
実行:
python3 _filename_
結果
AC  
実行時間 142 ms / 2,000 ms
+ 351µs
コード長 559 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 55 ms
コンパイル使用メモリ 14,848 KB
実行使用メモリ 29,492 KB
最終ジャッジ日時 2026-10-19 20:07:05
合計ジャッジ時間 6,226 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 51
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

import bisect
n, k = map(int, input().split())
x = list(map(int, input().split()))
a = list(map(int, input().split()))

idxl = k-1
idxr = k-1
l = x[k-1]
r = x[k-1]
allfrog = 0

while True:
    if idxl >= 0 and l  <= x[idxl]:
        l = min(l, x[idxl] - a[idxl])
        r = max(r, x[idxl] + a[idxl])
        idxl -= 1
    if idxr < n and r  >= x[idxr]:
        l = min(l, x[idxr] - a[idxr])
        r = max(r, x[idxr] + a[idxr])
        idxr += 1
    if allfrog == idxr-idxl-1:
        print(idxr-idxl-1)
        break
    else:
        allfrog = idxr-idxl-1
0