結果

問題 No.871 かえるのうた
ユーザー nadarenadare
提出日時 2019-08-30 22:09:34
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 187 ms / 2,000 ms
コード長 603 bytes
コンパイル時間 310 ms
コンパイル使用メモリ 82,304 KB
実行使用メモリ 98,816 KB
最終ジャッジ日時 2024-05-07 16:23:42
合計ジャッジ時間 5,571 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 38 ms
52,224 KB
testcase_01 AC 37 ms
51,712 KB
testcase_02 AC 37 ms
52,096 KB
testcase_03 AC 37 ms
52,352 KB
testcase_04 AC 37 ms
52,096 KB
testcase_05 AC 37 ms
51,968 KB
testcase_06 AC 38 ms
52,352 KB
testcase_07 AC 38 ms
52,352 KB
testcase_08 AC 45 ms
60,544 KB
testcase_09 AC 49 ms
62,464 KB
testcase_10 AC 54 ms
62,976 KB
testcase_11 AC 42 ms
58,752 KB
testcase_12 AC 63 ms
72,064 KB
testcase_13 AC 55 ms
64,384 KB
testcase_14 AC 94 ms
93,056 KB
testcase_15 AC 96 ms
92,800 KB
testcase_16 AC 187 ms
94,872 KB
testcase_17 AC 92 ms
92,928 KB
testcase_18 AC 51 ms
68,224 KB
testcase_19 AC 120 ms
94,344 KB
testcase_20 AC 76 ms
76,672 KB
testcase_21 AC 105 ms
85,120 KB
testcase_22 AC 38 ms
52,224 KB
testcase_23 AC 38 ms
52,480 KB
testcase_24 AC 38 ms
52,096 KB
testcase_25 AC 65 ms
70,016 KB
testcase_26 AC 85 ms
75,904 KB
testcase_27 AC 56 ms
67,840 KB
testcase_28 AC 36 ms
52,352 KB
testcase_29 AC 69 ms
87,296 KB
testcase_30 AC 153 ms
97,920 KB
testcase_31 AC 44 ms
59,008 KB
testcase_32 AC 145 ms
94,464 KB
testcase_33 AC 107 ms
95,360 KB
testcase_34 AC 53 ms
70,400 KB
testcase_35 AC 83 ms
92,288 KB
testcase_36 AC 85 ms
98,816 KB
testcase_37 AC 126 ms
86,784 KB
testcase_38 AC 184 ms
94,848 KB
testcase_39 AC 163 ms
93,312 KB
testcase_40 AC 146 ms
92,160 KB
testcase_41 AC 41 ms
52,480 KB
testcase_42 AC 123 ms
92,288 KB
testcase_43 AC 36 ms
51,968 KB
testcase_44 AC 38 ms
52,224 KB
testcase_45 AC 68 ms
69,760 KB
testcase_46 AC 37 ms
51,840 KB
testcase_47 AC 37 ms
52,096 KB
testcase_48 AC 38 ms
51,840 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from bisect import bisect, bisect_left
def inpl(): return list(map(int, input().split()))

N, K = inpl()
K -= 1
X= inpl()
A = inpl()

l = K
r = K
cl = K + 1
cr = K - 1

while (l < cl) or (cr < r):
    for x in range(cl-1, l-1, -1):
        cl -= 1
        nr = bisect(X, X[x] + A[x]) - 1
        r = min(max(r, nr), N-1)
        nl = bisect_left(X, X[x] - A[x])
        l = max(min(l, nl), 0)
    
    for x in range(cr+1, r+1):
        cr += 1
        nr = bisect(X, X[x] + A[x]) - 1
        r = min(max(r, nr), N-1)
        nl = bisect_left(X, X[x] - A[x])
        l = max(min(l, nl), 0)

print(r-l+1)
0