結果

問題 No.2354 Poor Sight in Winter
ユーザー lloyzlloyz
提出日時 2023-06-17 20:23:52
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,259 bytes
コンパイル時間 1,365 ms
コンパイル使用メモリ 87,032 KB
実行使用メモリ 78,396 KB
最終ジャッジ日時 2023-09-07 16:22:39
合計ジャッジ時間 4,845 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 91 ms
71,656 KB
testcase_01 AC 89 ms
71,576 KB
testcase_02 AC 90 ms
71,688 KB
testcase_03 AC 91 ms
71,900 KB
testcase_04 AC 92 ms
71,512 KB
testcase_05 AC 91 ms
71,656 KB
testcase_06 AC 90 ms
71,604 KB
testcase_07 AC 90 ms
71,552 KB
testcase_08 AC 91 ms
71,684 KB
testcase_09 WA -
testcase_10 AC 91 ms
71,484 KB
testcase_11 AC 121 ms
77,404 KB
testcase_12 AC 148 ms
78,296 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 128 ms
77,516 KB
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 AC 108 ms
77,320 KB
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 AC 114 ms
77,116 KB
testcase_26 AC 111 ms
77,236 KB
testcase_27 AC 99 ms
76,896 KB
testcase_28 AC 110 ms
77,712 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from heapq import heapify, heappop, heappush
from collections import deque

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
DD = [INF for _ in range(n + 2)]
DD[0] = 0
H = [(0, 0)]
while H:
    cd, cp = heappop(H)
    if cp == n + 1:
        break
    if cd > DD[cp]:
        continue
    for np in range(n + 2):
        if cd + D[cp][np] >= DD[np]:
            continue
        DD[np] = cd + D[cp][np]
        heappush(H, (DD[np], np))

R = []
cp = n + 1
while cp != 0:
    np = None
    res = INF
    for i in range(n + 2):
        if i == cp:
            continue
        if DD[i] + D[i][cp] == DD[cp]:
            if D[i][cp] < res:
                res = D[i][cp]
                np = i
    R.append(res)
    cp = np

m = len(R)
l, r = 0, abs(gx - sx) + abs(gy - sy)
while r - l > 1:
    mid = (l + r) // 2
    cnt = 0
    for i in range(m):
        d = R[i]
        cnt += (d - 1) // mid
    if cnt > k:
        l = mid
    else:
        r = mid
print(r)
0