結果

問題 No.2354 Poor Sight in Winter
ユーザー minimumminimum
提出日時 2023-06-16 22:38:20
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,773 ms / 2,000 ms
コード長 816 bytes
コンパイル時間 272 ms
コンパイル使用メモリ 87,224 KB
実行使用メモリ 79,712 KB
最終ジャッジ日時 2023-09-06 21:01:50
合計ジャッジ時間 13,207 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 68 ms
71,400 KB
testcase_01 AC 70 ms
71,536 KB
testcase_02 AC 65 ms
71,316 KB
testcase_03 AC 65 ms
71,488 KB
testcase_04 AC 68 ms
71,192 KB
testcase_05 AC 65 ms
71,536 KB
testcase_06 AC 66 ms
71,068 KB
testcase_07 AC 68 ms
71,080 KB
testcase_08 AC 68 ms
71,548 KB
testcase_09 AC 70 ms
75,652 KB
testcase_10 AC 79 ms
76,348 KB
testcase_11 AC 274 ms
78,048 KB
testcase_12 AC 273 ms
78,564 KB
testcase_13 AC 1,773 ms
79,192 KB
testcase_14 AC 1,278 ms
79,712 KB
testcase_15 AC 883 ms
79,408 KB
testcase_16 AC 1,173 ms
79,112 KB
testcase_17 AC 1,198 ms
78,616 KB
testcase_18 AC 471 ms
79,256 KB
testcase_19 AC 989 ms
78,724 KB
testcase_20 AC 496 ms
78,948 KB
testcase_21 AC 137 ms
78,888 KB
testcase_22 AC 269 ms
79,664 KB
testcase_23 AC 263 ms
79,336 KB
testcase_24 AC 609 ms
79,456 KB
testcase_25 AC 187 ms
77,684 KB
testcase_26 AC 182 ms
78,688 KB
testcase_27 AC 109 ms
77,600 KB
testcase_28 AC 136 ms
78,756 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from heapq import heappop, heappush


INF = 10 ** 18
C = 10 ** 7
N, K = map(int, input().split())
sx, sy, gx, gy = map(int, input().split())
X, Y = [sx, gx], [sy, gy]
for _ in range(N):
    x, y = map(int, input().split())
    X.append(x)
    Y.append(y)

def solve(P):
    hq = []
    heappush(hq, 0)
    dist = [INF] * (N + 2)
    dist[0] = 0
    while hq:
        now = heappop(hq) % C
        for i in range(N + 2):
            if now == i:
                continue
            ndist = dist[now] + (abs(X[i] - X[now]) + abs(Y[i] - Y[now]) - 1) // P
            if dist[i] > ndist:
                dist[i] = ndist
                heappush(hq, ndist * C + i)
    return dist[1] <= K


lo = 0
hi = 10 ** 6
while hi - lo > 1:
    p = (hi + lo) // 2
    if solve(p):
        hi = p
    else:
        lo = p

print(hi)
0