結果

問題 No.2354 Poor Sight in Winter
ユーザー minimumminimum
提出日時 2023-06-16 22:35:47
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,931 ms / 2,000 ms
コード長 806 bytes
コンパイル時間 263 ms
コンパイル使用メモリ 87,028 KB
実行使用メモリ 80,656 KB
最終ジャッジ日時 2023-09-06 20:56:56
合計ジャッジ時間 13,692 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 64 ms
71,532 KB
testcase_01 AC 73 ms
71,296 KB
testcase_02 AC 66 ms
71,360 KB
testcase_03 AC 64 ms
71,160 KB
testcase_04 AC 66 ms
71,508 KB
testcase_05 AC 65 ms
71,452 KB
testcase_06 AC 65 ms
71,008 KB
testcase_07 AC 66 ms
71,248 KB
testcase_08 AC 68 ms
71,080 KB
testcase_09 AC 74 ms
75,500 KB
testcase_10 AC 76 ms
76,240 KB
testcase_11 AC 276 ms
78,616 KB
testcase_12 AC 281 ms
78,708 KB
testcase_13 AC 1,931 ms
80,656 KB
testcase_14 AC 1,361 ms
79,676 KB
testcase_15 AC 952 ms
80,004 KB
testcase_16 AC 1,254 ms
80,576 KB
testcase_17 AC 1,262 ms
80,148 KB
testcase_18 AC 502 ms
79,716 KB
testcase_19 AC 1,022 ms
79,740 KB
testcase_20 AC 571 ms
79,204 KB
testcase_21 AC 153 ms
78,692 KB
testcase_22 AC 309 ms
79,672 KB
testcase_23 AC 331 ms
79,512 KB
testcase_24 AC 662 ms
79,552 KB
testcase_25 AC 208 ms
78,292 KB
testcase_26 AC 206 ms
78,848 KB
testcase_27 AC 124 ms
77,852 KB
testcase_28 AC 149 ms
78,740 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from heapq import heappop, heappush


INF = 10 ** 18
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, 0))
    dist = [INF] * (N + 2)
    dist[0] = 0
    while hq:
        _, now = heappop(hq)
        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, 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