結果

問題 No.871 かえるのうた
ユーザー FromBooskaFromBooska
提出日時 2023-02-27 15:10:23
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 881 bytes
コンパイル時間 1,109 ms
コンパイル使用メモリ 86,612 KB
実行使用メモリ 111,772 KB
最終ジャッジ日時 2023-10-13 00:38:05
合計ジャッジ時間 8,111 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 97 ms
71,288 KB
testcase_01 AC 94 ms
71,536 KB
testcase_02 AC 98 ms
71,588 KB
testcase_03 AC 94 ms
71,724 KB
testcase_04 AC 92 ms
71,440 KB
testcase_05 AC 92 ms
71,568 KB
testcase_06 AC 91 ms
71,572 KB
testcase_07 AC 92 ms
71,428 KB
testcase_08 AC 105 ms
77,320 KB
testcase_09 AC 105 ms
78,368 KB
testcase_10 AC 120 ms
77,964 KB
testcase_11 AC 100 ms
76,992 KB
testcase_12 AC 118 ms
81,576 KB
testcase_13 AC 112 ms
77,924 KB
testcase_14 AC 160 ms
101,372 KB
testcase_15 AC 161 ms
102,024 KB
testcase_16 TLE -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
testcase_39 -- -
testcase_40 -- -
testcase_41 -- -
testcase_42 -- -
testcase_43 -- -
testcase_44 -- -
testcase_45 -- -
testcase_46 -- -
testcase_47 -- -
testcase_48 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

# アイディアその1。dequeでシミュレーション、bisect, visited管理
# アイディアその2。グラフ化して届く頂点に有効辺張る、スタートから辿り着ける頂点の個数
# どっちでも行ける気がする

# deque案
N, K = map(int, input().split())
INF = 10**20
X = [-INF]+list(map(int, input().split()))+[INF]
A = [0]+list(map(int, input().split()))+[0]

from collections import deque
from bisect import *
que = deque()
que.append(K)
visited = [0]*(N+1)
visited[K] = 1
while que:
    current = que.popleft()
    lower = bisect_left(X, X[current]-A[current])
    upper = bisect_left(X, X[current]+A[current])
    if X[upper] != X[current]+A[current]:
        upper -= 1
    for nxt in range(lower, upper+1):
        if visited[nxt] == 0:
            visited[nxt] = 1
            que.append(nxt)

print(sum(visited))

#print(visited)


0