結果
| 問題 |
No.871 かえるのうた
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2022-07-23 17:38:47 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 624 bytes |
| コンパイル時間 | 251 ms |
| コンパイル使用メモリ | 81,912 KB |
| 実行使用メモリ | 275,232 KB |
| 最終ジャッジ日時 | 2024-07-05 07:07:54 |
| 合計ジャッジ時間 | 4,394 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 3 TLE * 1 -- * 45 |
ソースコード
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])
for i in range(nl,l):
#if ans[i] == 1:
# break
d.append(i)
ans[i] = 1
for i in range(nr-1,r-1,-1):
#if ans[i] == 1:
# break
d.append(i)
ans[i] = 1
l = nl
r = nr
print(sum(ans))