結果

問題 No.871 かえるのうた
ユーザー nadarenadare
提出日時 2019-08-30 22:09:34
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 273 ms / 2,000 ms
コード長 603 bytes
コンパイル時間 1,629 ms
コンパイル使用メモリ 87,200 KB
実行使用メモリ 95,796 KB
最終ジャッジ日時 2023-08-20 09:19:44
合計ジャッジ時間 8,530 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 76 ms
71,060 KB
testcase_01 AC 76 ms
71,072 KB
testcase_02 AC 75 ms
71,164 KB
testcase_03 AC 76 ms
70,936 KB
testcase_04 AC 75 ms
71,120 KB
testcase_05 AC 74 ms
71,008 KB
testcase_06 AC 75 ms
70,936 KB
testcase_07 AC 77 ms
71,064 KB
testcase_08 AC 99 ms
75,820 KB
testcase_09 AC 84 ms
75,832 KB
testcase_10 AC 88 ms
75,812 KB
testcase_11 AC 81 ms
75,368 KB
testcase_12 AC 95 ms
78,016 KB
testcase_13 AC 87 ms
75,812 KB
testcase_14 AC 124 ms
93,384 KB
testcase_15 AC 127 ms
93,500 KB
testcase_16 AC 273 ms
95,796 KB
testcase_17 AC 123 ms
93,232 KB
testcase_18 AC 86 ms
78,012 KB
testcase_19 AC 152 ms
95,392 KB
testcase_20 AC 106 ms
77,120 KB
testcase_21 AC 136 ms
86,172 KB
testcase_22 AC 75 ms
71,168 KB
testcase_23 AC 74 ms
70,928 KB
testcase_24 AC 75 ms
71,148 KB
testcase_25 AC 94 ms
76,280 KB
testcase_26 AC 110 ms
77,272 KB
testcase_27 AC 85 ms
76,404 KB
testcase_28 AC 73 ms
71,156 KB
testcase_29 AC 98 ms
92,872 KB
testcase_30 AC 185 ms
94,564 KB
testcase_31 AC 78 ms
75,336 KB
testcase_32 AC 171 ms
94,856 KB
testcase_33 AC 135 ms
94,108 KB
testcase_34 AC 85 ms
80,124 KB
testcase_35 AC 112 ms
93,164 KB
testcase_36 AC 112 ms
92,928 KB
testcase_37 AC 154 ms
87,380 KB
testcase_38 AC 210 ms
93,924 KB
testcase_39 AC 194 ms
92,936 KB
testcase_40 AC 169 ms
93,280 KB
testcase_41 AC 73 ms
71,044 KB
testcase_42 AC 150 ms
92,996 KB
testcase_43 AC 73 ms
71,212 KB
testcase_44 AC 74 ms
71,100 KB
testcase_45 AC 95 ms
76,332 KB
testcase_46 AC 73 ms
71,104 KB
testcase_47 AC 75 ms
70,780 KB
testcase_48 AC 75 ms
71,216 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