結果

問題 No.871 かえるのうた
ユーザー kept1994kept1994
提出日時 2021-08-31 18:51:36
言語 PyPy3
(7.3.15)
結果
MLE  
実行時間 -
コード長 1,009 bytes
コンパイル時間 298 ms
コンパイル使用メモリ 87,284 KB
実行使用メモリ 847,516 KB
最終ジャッジ日時 2023-08-17 07:38:49
合計ジャッジ時間 8,408 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 98 ms
71,760 KB
testcase_01 AC 99 ms
71,924 KB
testcase_02 AC 97 ms
71,940 KB
testcase_03 AC 98 ms
71,564 KB
testcase_04 AC 99 ms
71,720 KB
testcase_05 AC 97 ms
71,752 KB
testcase_06 AC 97 ms
71,804 KB
testcase_07 AC 98 ms
71,624 KB
testcase_08 AC 125 ms
77,976 KB
testcase_09 AC 126 ms
78,124 KB
testcase_10 AC 123 ms
78,148 KB
testcase_11 AC 121 ms
78,152 KB
testcase_12 AC 151 ms
82,524 KB
testcase_13 AC 129 ms
77,852 KB
testcase_14 AC 259 ms
106,476 KB
testcase_15 AC 262 ms
106,600 KB
testcase_16 MLE -
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 #

#!/usr/bin/env python3
import sys

def main():
    from collections import deque
    INF = 10 ** 16
    def bfs(edges: "List[to]", start_node: int) -> list:
        q = deque()
        dist = [INF] * len(edges)
        q.append(start_node)
        dist[start_node] = 0
        while q:
            now = q.popleft()
            for next in edges[now]:
                if dist[next] != INF:
                    continue
                q.append(next)
                dist[next] = dist[now] + 1
        return dist
    import bisect
    N, K = map(int, input().split())
    X = list(map(int, input().split()))
    A = list(map(int, input().split()))
    G = [[] for _ in range(N)]
    for i in range(N):
        l = bisect.bisect_left(X, X[i] - A[i])
        r = bisect.bisect_right(X, X[i] + A[i])
        for j in range(l, r):
            if i == j:
                continue
            G[i].append(j)
    d = bfs(G, K - 1)
    print(N - d.count(INF))
    return
        
if __name__ == '__main__':
    main()
0