結果

問題 No.871 かえるのうた
ユーザー 👑 timitimi
提出日時 2021-03-08 15:42:07
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 382 ms / 2,000 ms
コード長 664 bytes
コンパイル時間 219 ms
コンパイル使用メモリ 10,752 KB
実行使用メモリ 30,928 KB
最終ジャッジ日時 2023-08-20 09:38:54
合計ジャッジ時間 7,390 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 19 ms
8,572 KB
testcase_01 AC 21 ms
8,568 KB
testcase_02 AC 21 ms
8,624 KB
testcase_03 AC 21 ms
8,476 KB
testcase_04 AC 20 ms
8,648 KB
testcase_05 AC 20 ms
8,656 KB
testcase_06 AC 19 ms
8,568 KB
testcase_07 AC 19 ms
8,656 KB
testcase_08 AC 26 ms
9,140 KB
testcase_09 AC 27 ms
9,488 KB
testcase_10 AC 21 ms
8,668 KB
testcase_11 AC 23 ms
8,892 KB
testcase_12 AC 61 ms
12,920 KB
testcase_13 AC 29 ms
9,532 KB
testcase_14 AC 260 ms
30,592 KB
testcase_15 AC 253 ms
30,632 KB
testcase_16 AC 382 ms
30,868 KB
testcase_17 AC 242 ms
29,204 KB
testcase_18 AC 62 ms
12,256 KB
testcase_19 AC 262 ms
30,908 KB
testcase_20 AC 50 ms
10,520 KB
testcase_21 AC 119 ms
16,620 KB
testcase_22 AC 20 ms
8,652 KB
testcase_23 AC 20 ms
8,656 KB
testcase_24 AC 20 ms
8,540 KB
testcase_25 AC 27 ms
9,108 KB
testcase_26 AC 54 ms
10,800 KB
testcase_27 AC 54 ms
11,756 KB
testcase_28 AC 19 ms
8,572 KB
testcase_29 AC 154 ms
21,168 KB
testcase_30 AC 263 ms
25,080 KB
testcase_31 AC 25 ms
9,124 KB
testcase_32 AC 227 ms
23,140 KB
testcase_33 AC 256 ms
30,928 KB
testcase_34 AC 77 ms
14,428 KB
testcase_35 AC 156 ms
22,020 KB
testcase_36 AC 207 ms
26,980 KB
testcase_37 AC 154 ms
18,060 KB
testcase_38 AC 338 ms
30,500 KB
testcase_39 AC 315 ms
29,132 KB
testcase_40 AC 231 ms
21,656 KB
testcase_41 AC 19 ms
8,560 KB
testcase_42 AC 234 ms
23,880 KB
testcase_43 AC 19 ms
8,560 KB
testcase_44 AC 20 ms
8,652 KB
testcase_45 AC 25 ms
8,988 KB
testcase_46 AC 19 ms
8,468 KB
testcase_47 AC 19 ms
8,700 KB
testcase_48 AC 19 ms
8,528 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N,K=map(int, input().split())
X=list(map(int, input().split()))
A=list(map(int, input().split()))
import bisect
D=[]
for i in range(N):
  l=bisect.bisect_left(X,X[i]-A[i])
  r=bisect.bisect_right(X,X[i]+A[i])-1
  D.append((l,r))
#print(D)
from collections import deque
d=deque()
d.append(K-1)
E=[0]*N
E[K-1]=1
ll,rr=K-1,K-1
while d:
  now=d.popleft()
  l,r=D[now]
  if 0<ll:
    if l<ll:
      for i in range(l,ll):
        if E[i]==1:
          break
        else:
          E[i]=1
          d.append(i)
  if rr<N-1:
    if rr<r:
      for i in range(r,rr,-1):
        if E[i]==1:
          break
        else:
          E[i]=1
          d.append(i)
print(sum(E))
0