結果

問題 No.871 かえるのうた
ユーザー daku9640daku9640
提出日時 2019-08-30 22:40:19
言語 Python3
(3.11.6 + numpy 1.26.0 + scipy 1.11.3)
結果
AC  
実行時間 195 ms / 2,000 ms
コード長 669 bytes
コンパイル時間 284 ms
コンパイル使用メモリ 10,720 KB
実行使用メモリ 25,972 KB
最終ジャッジ日時 2023-08-20 09:20:51
合計ジャッジ時間 4,562 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
7,976 KB
testcase_01 AC 16 ms
7,956 KB
testcase_02 AC 17 ms
7,956 KB
testcase_03 AC 16 ms
7,948 KB
testcase_04 AC 17 ms
7,884 KB
testcase_05 AC 16 ms
7,968 KB
testcase_06 AC 17 ms
8,072 KB
testcase_07 AC 17 ms
8,168 KB
testcase_08 AC 18 ms
8,656 KB
testcase_09 AC 20 ms
8,944 KB
testcase_10 AC 17 ms
7,956 KB
testcase_11 AC 18 ms
8,320 KB
testcase_12 AC 30 ms
11,752 KB
testcase_13 AC 20 ms
8,860 KB
testcase_14 AC 97 ms
25,500 KB
testcase_15 AC 94 ms
25,704 KB
testcase_16 AC 104 ms
25,732 KB
testcase_17 AC 91 ms
24,736 KB
testcase_18 AC 31 ms
11,708 KB
testcase_19 AC 100 ms
25,972 KB
testcase_20 AC 23 ms
9,628 KB
testcase_21 AC 49 ms
14,836 KB
testcase_22 AC 17 ms
7,888 KB
testcase_23 AC 16 ms
8,156 KB
testcase_24 AC 16 ms
8,072 KB
testcase_25 AC 18 ms
8,552 KB
testcase_26 AC 24 ms
9,748 KB
testcase_27 AC 27 ms
10,636 KB
testcase_28 AC 16 ms
7,960 KB
testcase_29 AC 55 ms
16,464 KB
testcase_30 AC 77 ms
21,516 KB
testcase_31 AC 18 ms
8,648 KB
testcase_32 AC 72 ms
19,968 KB
testcase_33 AC 94 ms
25,824 KB
testcase_34 AC 35 ms
12,964 KB
testcase_35 AC 60 ms
19,012 KB
testcase_36 AC 78 ms
23,016 KB
testcase_37 AC 51 ms
15,952 KB
testcase_38 AC 98 ms
25,680 KB
testcase_39 AC 96 ms
24,512 KB
testcase_40 AC 195 ms
17,036 KB
testcase_41 AC 17 ms
8,004 KB
testcase_42 AC 61 ms
17,656 KB
testcase_43 AC 16 ms
7,888 KB
testcase_44 AC 16 ms
7,972 KB
testcase_45 AC 22 ms
8,396 KB
testcase_46 AC 16 ms
7,956 KB
testcase_47 AC 17 ms
7,920 KB
testcase_48 AC 17 ms
7,960 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