結果

問題 No.871 かえるのうた
ユーザー yomo3yomo3
提出日時 2020-02-26 14:43:26
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 736 bytes
コンパイル時間 375 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 28,288 KB
最終ジャッジ日時 2024-04-21 16:24:27
合計ジャッジ時間 4,953 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 28 ms
10,752 KB
testcase_01 AC 26 ms
10,624 KB
testcase_02 AC 26 ms
10,624 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 27 ms
10,752 KB
testcase_06 WA -
testcase_07 AC 27 ms
10,624 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 AC 27 ms
11,008 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 AC 93 ms
26,628 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 AC 90 ms
25,484 KB
testcase_18 AC 37 ms
13,272 KB
testcase_19 WA -
testcase_20 AC 38 ms
12,084 KB
testcase_21 WA -
testcase_22 AC 27 ms
10,752 KB
testcase_23 AC 27 ms
10,752 KB
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 AC 28 ms
10,624 KB
testcase_29 AC 62 ms
17,752 KB
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 AC 42 ms
14,728 KB
testcase_35 WA -
testcase_36 AC 77 ms
22,384 KB
testcase_37 WA -
testcase_38 WA -
testcase_39 WA -
testcase_40 WA -
testcase_41 AC 27 ms
10,624 KB
testcase_42 AC 108 ms
17,372 KB
testcase_43 WA -
testcase_44 WA -
testcase_45 WA -
testcase_46 AC 27 ms
10,624 KB
testcase_47 AC 26 ms
10,752 KB
testcase_48 AC 28 ms
10,624 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 = 1
q = deque()
q.append(K)
lk = rk = K
l = r = X[K]
while len(q):
    k = q.popleft()
    _l = X[k] - A[k]
    _r = X[k] + A[k]

    if _l < l:
        _lk = bisect_left(X, _l)
        if _lk < lk:
            for i in range(lk-1, _lk-1, -1):
                q.append(i)
                ans += 1
            lk = _lk
        l = _l

    if _r > r:
        _rk = bisect_right(X, _r)
        if _rk > rk:
            for i in range(rk+1, _rk):
                q.append(i)
                ans += 1
            rk = _rk
        r = _r

print(ans)
0