結果

問題 No.871 かえるのうた
ユーザー Mine
提出日時 2020-09-06 23:15:08
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 246 ms / 2,000 ms
コード長 559 bytes
コンパイル時間 84 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 29,008 KB
最終ジャッジ日時 2024-11-30 11:04:08
合計ジャッジ時間 5,054 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 49
権限があれば一括ダウンロードができます

ソースコード

diff #

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