結果

問題 No.871 かえるのうた
ユーザー daku9640daku9640
提出日時 2019-08-30 22:40:19
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 196 ms / 2,000 ms
コード長 669 bytes
コンパイル時間 84 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 29,956 KB
最終ジャッジ日時 2024-05-07 16:25:00
合計ジャッジ時間 4,239 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 25 ms
10,624 KB
testcase_01 AC 26 ms
10,624 KB
testcase_02 AC 25 ms
10,624 KB
testcase_03 AC 26 ms
10,752 KB
testcase_04 AC 28 ms
10,752 KB
testcase_05 AC 29 ms
10,752 KB
testcase_06 AC 28 ms
10,624 KB
testcase_07 AC 27 ms
10,624 KB
testcase_08 AC 29 ms
11,008 KB
testcase_09 AC 29 ms
11,264 KB
testcase_10 AC 28 ms
10,752 KB
testcase_11 AC 27 ms
11,008 KB
testcase_12 AC 40 ms
14,024 KB
testcase_13 AC 29 ms
11,392 KB
testcase_14 AC 114 ms
29,540 KB
testcase_15 AC 111 ms
29,640 KB
testcase_16 AC 116 ms
27,944 KB
testcase_17 AC 103 ms
27,816 KB
testcase_18 AC 40 ms
13,624 KB
testcase_19 AC 112 ms
29,956 KB
testcase_20 AC 33 ms
12,220 KB
testcase_21 AC 60 ms
17,196 KB
testcase_22 AC 26 ms
10,752 KB
testcase_23 AC 26 ms
10,624 KB
testcase_24 AC 26 ms
10,624 KB
testcase_25 AC 28 ms
11,136 KB
testcase_26 AC 33 ms
12,288 KB
testcase_27 AC 39 ms
13,056 KB
testcase_28 AC 28 ms
10,624 KB
testcase_29 AC 70 ms
19,004 KB
testcase_30 AC 91 ms
24,052 KB
testcase_31 AC 28 ms
11,136 KB
testcase_32 AC 81 ms
22,336 KB
testcase_33 AC 104 ms
28,524 KB
testcase_34 AC 45 ms
15,388 KB
testcase_35 AC 72 ms
21,544 KB
testcase_36 AC 92 ms
25,696 KB
testcase_37 AC 63 ms
18,232 KB
testcase_38 AC 107 ms
27,468 KB
testcase_39 AC 108 ms
27,200 KB
testcase_40 AC 196 ms
19,488 KB
testcase_41 AC 27 ms
10,752 KB
testcase_42 AC 73 ms
20,132 KB
testcase_43 AC 27 ms
10,624 KB
testcase_44 AC 29 ms
10,752 KB
testcase_45 AC 33 ms
11,008 KB
testcase_46 AC 27 ms
10,624 KB
testcase_47 AC 27 ms
10,624 KB
testcase_48 AC 28 ms
10,624 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from bisect import bisect_left, bisect, insort_left, insort
def solve():
    n, k = map(int, input().split())
    k -= 1
    X = list(map(int, input().split()))
    A = list(map(int, input().split()))
    L = [X[i] - A[i] for i in range(n)]
    R = [X[i] + A[i] for i in range(n)]
    l = r = k
    flg = True
    min_x, max_x = L[k], R[k]
    while flg:
        flg = False
        lt = bisect_left(X, min_x)
        rt = bisect(X, max_x) - 1
        min_x = min(min_x, min(L[lt:l + 1]), min(L[r :rt + 1]))
        max_x = max(max_x, max(R[lt:l + 1]), max(R[r :rt + 1]))
        if l != lt or r != rt:
            l, r, flg = lt, rt, True
    print(r - l + 1)
solve()
0