結果

問題 No.871 かえるのうた
ユーザー lloyzlloyz
提出日時 2022-04-19 00:19:50
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 312 ms / 2,000 ms
コード長 772 bytes
コンパイル時間 893 ms
コンパイル使用メモリ 87,092 KB
実行使用メモリ 109,528 KB
最終ジャッジ日時 2023-08-20 09:43:08
合計ジャッジ時間 10,108 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 104 ms
71,556 KB
testcase_01 AC 103 ms
71,632 KB
testcase_02 AC 103 ms
71,556 KB
testcase_03 AC 101 ms
71,356 KB
testcase_04 AC 104 ms
71,732 KB
testcase_05 AC 103 ms
71,808 KB
testcase_06 AC 105 ms
71,700 KB
testcase_07 AC 100 ms
71,800 KB
testcase_08 AC 112 ms
77,088 KB
testcase_09 AC 115 ms
77,092 KB
testcase_10 AC 121 ms
77,552 KB
testcase_11 AC 111 ms
76,908 KB
testcase_12 AC 125 ms
79,328 KB
testcase_13 AC 120 ms
77,332 KB
testcase_14 AC 159 ms
106,796 KB
testcase_15 AC 171 ms
106,676 KB
testcase_16 AC 312 ms
105,540 KB
testcase_17 AC 158 ms
109,084 KB
testcase_18 AC 114 ms
79,716 KB
testcase_19 AC 181 ms
106,696 KB
testcase_20 AC 128 ms
78,184 KB
testcase_21 AC 165 ms
87,564 KB
testcase_22 AC 101 ms
71,408 KB
testcase_23 AC 104 ms
71,656 KB
testcase_24 AC 101 ms
71,812 KB
testcase_25 AC 143 ms
77,896 KB
testcase_26 AC 148 ms
79,552 KB
testcase_27 AC 119 ms
77,388 KB
testcase_28 AC 103 ms
71,612 KB
testcase_29 AC 133 ms
94,304 KB
testcase_30 AC 229 ms
99,880 KB
testcase_31 AC 111 ms
76,672 KB
testcase_32 AC 205 ms
97,328 KB
testcase_33 AC 169 ms
107,244 KB
testcase_34 AC 115 ms
81,496 KB
testcase_35 AC 141 ms
94,392 KB
testcase_36 AC 144 ms
103,236 KB
testcase_37 AC 187 ms
89,268 KB
testcase_38 AC 274 ms
109,528 KB
testcase_39 AC 242 ms
105,160 KB
testcase_40 AC 217 ms
94,772 KB
testcase_41 AC 102 ms
71,644 KB
testcase_42 AC 203 ms
106,732 KB
testcase_43 AC 101 ms
71,712 KB
testcase_44 AC 99 ms
71,904 KB
testcase_45 AC 142 ms
78,076 KB
testcase_46 AC 103 ms
71,656 KB
testcase_47 AC 100 ms
71,696 KB
testcase_48 AC 103 ms
71,616 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from bisect import bisect_left, bisect_right
from collections import deque

n, k = map(int, input().split())
k -= 1
X = list(map(int, input().split()))
A = list(map(int, input().split()))

Que = deque([k])
seen = set([k])
left, right = k, k
while Que:
    idx = Que.popleft()
    l, r = X[idx] - A[idx], X[idx] + A[idx]
    lidx = bisect_left(X, l)
    ridx = bisect_right(X, r) - 1
    if lidx < left:
        for i in range(lidx, left):
            if i in seen:
                continue
            seen.add(i)
            Que.append(i)
        left = lidx
    if ridx > right:
        for i in range(right + 1, ridx + 1):
            if i in seen:
                continue
            seen.add(i)
            Que.append(i)
        right = ridx
print(right - left + 1)
0