結果

問題 No.2354 Poor Sight in Winter
ユーザー lloyzlloyz
提出日時 2023-06-17 20:39:38
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 636 ms / 2,000 ms
コード長 965 bytes
コンパイル時間 264 ms
コンパイル使用メモリ 87,164 KB
実行使用メモリ 82,948 KB
最終ジャッジ日時 2023-09-07 16:33:44
合計ジャッジ時間 9,290 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 74 ms
71,672 KB
testcase_01 AC 72 ms
71,636 KB
testcase_02 AC 76 ms
71,676 KB
testcase_03 AC 74 ms
71,472 KB
testcase_04 AC 74 ms
71,316 KB
testcase_05 AC 74 ms
71,672 KB
testcase_06 AC 75 ms
71,680 KB
testcase_07 AC 73 ms
71,476 KB
testcase_08 AC 73 ms
71,332 KB
testcase_09 AC 88 ms
76,924 KB
testcase_10 AC 92 ms
76,572 KB
testcase_11 AC 402 ms
80,600 KB
testcase_12 AC 484 ms
80,776 KB
testcase_13 AC 572 ms
82,808 KB
testcase_14 AC 636 ms
82,396 KB
testcase_15 AC 478 ms
81,360 KB
testcase_16 AC 591 ms
82,948 KB
testcase_17 AC 585 ms
82,828 KB
testcase_18 AC 327 ms
81,084 KB
testcase_19 AC 461 ms
81,820 KB
testcase_20 AC 299 ms
80,392 KB
testcase_21 AC 183 ms
78,976 KB
testcase_22 AC 298 ms
80,492 KB
testcase_23 AC 257 ms
80,520 KB
testcase_24 AC 418 ms
81,736 KB
testcase_25 AC 220 ms
79,884 KB
testcase_26 AC 230 ms
79,816 KB
testcase_27 AC 140 ms
78,636 KB
testcase_28 AC 173 ms
79,176 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from heapq import heapify, heappop, heappush

n, k = map(int, input().split())
sx, sy, gx, gy = map(int, input().split())
P = [list(map(int, input().split())) for _ in range(n)]
P = [[sx, sy]] + P + [[gx, gy]]
D = [[0 for _ in range(n + 2)] for _ in range(n + 2)]
for i in range(n + 2):
    for j in range(n + 2):
        D[i][j] = abs(P[i][0] - P[j][0]) + abs(P[i][1] - P[j][1])

INF = 10**18
l, r = 0, INF
while r - l > 1:
    mid = (l + r) // 2
    C = [INF for _ in range(n + 2)]
    C[0] = 0
    H = [(0, 0)]
    while H:
        ccnt, cp = heappop(H)
        if cp == n + 1:
            break
        if ccnt > C[cp]:
            continue
        for np in range(n + 2):
            if np == cp:
                continue
            ncnt = ccnt + (D[cp][np] - 1) // mid
            if ncnt >= C[np]:
                continue
            C[np] = ncnt
            heappush(H, (C[np], np))
    if C[n + 1] > k:
        l = mid
    else:
        r = mid
print(r)
0