結果

問題 No.871 かえるのうた
ユーザー stngstng
提出日時 2022-07-23 17:06:07
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 785 bytes
コンパイル時間 449 ms
コンパイル使用メモリ 86,964 KB
実行使用メモリ 103,244 KB
最終ジャッジ日時 2023-09-18 15:58:31
合計ジャッジ時間 13,270 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 93 ms
71,864 KB
testcase_01 AC 91 ms
71,760 KB
testcase_02 AC 91 ms
71,692 KB
testcase_03 AC 92 ms
71,560 KB
testcase_04 AC 92 ms
71,728 KB
testcase_05 AC 92 ms
71,744 KB
testcase_06 AC 92 ms
71,652 KB
testcase_07 AC 96 ms
71,664 KB
testcase_08 AC 105 ms
77,404 KB
testcase_09 AC 105 ms
77,304 KB
testcase_10 AC 118 ms
77,724 KB
testcase_11 AC 100 ms
77,028 KB
testcase_12 AC 118 ms
79,368 KB
testcase_13 AC 113 ms
77,848 KB
testcase_14 AC 148 ms
102,928 KB
testcase_15 AC 150 ms
103,140 KB
testcase_16 AC 1,435 ms
101,940 KB
testcase_17 AC 138 ms
99,116 KB
testcase_18 AC 105 ms
79,184 KB
testcase_19 AC 184 ms
103,244 KB
testcase_20 AC 118 ms
78,112 KB
testcase_21 AC 171 ms
85,284 KB
testcase_22 AC 93 ms
71,564 KB
testcase_23 AC 90 ms
71,580 KB
testcase_24 AC 91 ms
71,732 KB
testcase_25 AC 131 ms
78,696 KB
testcase_26 AC 149 ms
78,832 KB
testcase_27 AC 110 ms
77,616 KB
testcase_28 AC 93 ms
71,672 KB
testcase_29 AC 115 ms
88,220 KB
testcase_30 AC 263 ms
93,576 KB
testcase_31 AC 100 ms
76,916 KB
testcase_32 AC 268 ms
91,436 KB
testcase_33 AC 158 ms
97,612 KB
testcase_34 AC 108 ms
80,376 KB
testcase_35 AC 133 ms
89,540 KB
testcase_36 AC 128 ms
94,600 KB
testcase_37 AC 231 ms
86,096 KB
testcase_38 AC 313 ms
99,692 KB
testcase_39 AC 515 ms
97,376 KB
testcase_40 TLE -
testcase_41 AC 93 ms
71,588 KB
testcase_42 AC 181 ms
90,292 KB
testcase_43 AC 91 ms
71,836 KB
testcase_44 AC 95 ms
71,912 KB
testcase_45 AC 119 ms
78,020 KB
testcase_46 AC 92 ms
71,644 KB
testcase_47 AC 93 ms
71,548 KB
testcase_48 AC 93 ms
71,752 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import deque
import bisect

n,k = map(int,input().split())
x = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]

ans = [0]*(n)

d = deque()
d.append(k-1)
l = k-1
r = k-1
ans[k-1] = 1

while len(d):
    tmp = d.popleft()
    pos = x[tmp]
    nl = bisect.bisect_left(x,pos-a[tmp])
    nr = bisect.bisect_right(x,pos+a[tmp])
    #print(nl,nr)
    #exit()
    if nl < l:
        for i in range(nl,l):
            #print(i,"ll")
            if ans[i] == 1:
                continue
            d.append(i)
            ans[i] = 1
    if nr > r:
        for i in range(r,nr):
            #print(i,"rr")
            if ans[i] == 1:
                continue
            d.append(i)
            ans[i] = 1
    #exit()
    l = nl
    r = nr
print(sum(ans))
0