結果

問題 No.871 かえるのうた
ユーザー yomo3yomo3
提出日時 2020-02-26 19:16:52
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 393 ms / 2,000 ms
コード長 507 bytes
コンパイル時間 133 ms
コンパイル使用メモリ 10,792 KB
実行使用メモリ 28,300 KB
最終ジャッジ日時 2023-08-20 09:33:30
合計ジャッジ時間 5,969 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 21 ms
8,508 KB
testcase_01 AC 19 ms
8,456 KB
testcase_02 AC 19 ms
8,484 KB
testcase_03 AC 19 ms
8,492 KB
testcase_04 AC 19 ms
8,620 KB
testcase_05 AC 19 ms
8,532 KB
testcase_06 AC 19 ms
8,488 KB
testcase_07 AC 20 ms
8,448 KB
testcase_08 AC 21 ms
8,912 KB
testcase_09 AC 22 ms
9,068 KB
testcase_10 AC 22 ms
8,512 KB
testcase_11 AC 21 ms
8,680 KB
testcase_12 AC 32 ms
11,544 KB
testcase_13 AC 24 ms
9,252 KB
testcase_14 AC 88 ms
26,272 KB
testcase_15 AC 86 ms
25,732 KB
testcase_16 AC 393 ms
28,300 KB
testcase_17 AC 80 ms
22,968 KB
testcase_18 AC 30 ms
11,248 KB
testcase_19 AC 99 ms
24,364 KB
testcase_20 AC 46 ms
9,888 KB
testcase_21 AC 87 ms
14,976 KB
testcase_22 AC 19 ms
8,468 KB
testcase_23 AC 19 ms
8,668 KB
testcase_24 AC 19 ms
8,600 KB
testcase_25 AC 27 ms
8,852 KB
testcase_26 AC 53 ms
9,760 KB
testcase_27 AC 29 ms
10,912 KB
testcase_28 AC 19 ms
8,580 KB
testcase_29 AC 50 ms
15,452 KB
testcase_30 AC 270 ms
20,452 KB
testcase_31 AC 20 ms
8,984 KB
testcase_32 AC 204 ms
18,780 KB
testcase_33 AC 87 ms
24,652 KB
testcase_34 AC 35 ms
12,820 KB
testcase_35 AC 57 ms
18,016 KB
testcase_36 AC 70 ms
21,200 KB
testcase_37 AC 160 ms
15,532 KB
testcase_38 AC 345 ms
24,756 KB
testcase_39 AC 296 ms
22,292 KB
testcase_40 AC 242 ms
16,072 KB
testcase_41 AC 20 ms
8,468 KB
testcase_42 AC 234 ms
16,180 KB
testcase_43 AC 19 ms
8,656 KB
testcase_44 AC 20 ms
8,512 KB
testcase_45 AC 25 ms
8,628 KB
testcase_46 AC 20 ms
8,512 KB
testcase_47 AC 20 ms
8,596 KB
testcase_48 AC 20 ms
8,516 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import deque
from bisect import bisect_left, bisect_right

N, K = map(int, input().split())
X = list(map(int, input().split()))
A = list(map(int, input().split()))
K -= 1

ans = 0
q = deque()
q.append(K)
l = r = K
while len(q):
    k = q.popleft()
    ans += 1
    _l = bisect_left(X, X[k] - A[k])
    for i in range(_l, l):
        q.append(i)
    l = min(l, _l)

    _r = bisect_right(X, X[k] + A[k]) - 1
    for i in range(r+1, _r + 1):
        q.append(i)
    r = max(r, _r)

print(ans)
0