結果

問題 No.2354 Poor Sight in Winter
ユーザー 👑 SPD_9X2SPD_9X2
提出日時 2023-06-16 22:30:05
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 533 ms / 2,000 ms
コード長 845 bytes
コンパイル時間 535 ms
コンパイル使用メモリ 86,616 KB
実行使用メモリ 81,236 KB
最終ジャッジ日時 2023-09-06 20:45:12
合計ジャッジ時間 8,533 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 75 ms
71,296 KB
testcase_01 AC 78 ms
70,944 KB
testcase_02 AC 75 ms
71,096 KB
testcase_03 AC 73 ms
71,184 KB
testcase_04 AC 75 ms
71,004 KB
testcase_05 AC 75 ms
71,156 KB
testcase_06 AC 75 ms
71,220 KB
testcase_07 AC 75 ms
71,220 KB
testcase_08 AC 73 ms
71,348 KB
testcase_09 AC 77 ms
70,836 KB
testcase_10 AC 84 ms
75,884 KB
testcase_11 AC 289 ms
80,748 KB
testcase_12 AC 236 ms
78,872 KB
testcase_13 AC 523 ms
80,280 KB
testcase_14 AC 533 ms
80,840 KB
testcase_15 AC 483 ms
80,472 KB
testcase_16 AC 506 ms
81,236 KB
testcase_17 AC 532 ms
80,676 KB
testcase_18 AC 340 ms
80,624 KB
testcase_19 AC 425 ms
80,552 KB
testcase_20 AC 359 ms
79,820 KB
testcase_21 AC 187 ms
78,644 KB
testcase_22 AC 283 ms
79,364 KB
testcase_23 AC 285 ms
79,996 KB
testcase_24 AC 406 ms
81,016 KB
testcase_25 AC 217 ms
79,076 KB
testcase_26 AC 224 ms
78,600 KB
testcase_27 AC 128 ms
77,424 KB
testcase_28 AC 173 ms
78,464 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
from sys import stdin
import math
import heapq

N,K = map(int,stdin.readline().split())

sx,sy,gx,gy = map(int,stdin.readline().split())

xy = [(sx,sy)]
for i in range(N):
    x,y = map(int,stdin.readline().split())
    xy.append((x,y))
xy.append((gx,gy))

N += 2

l = 0
r = abs(sx-gx) + abs(sy-gy) + 1

while r-l != 1:

    P = (l+r)//2

    d = [float("inf")] * N
    d[0] = 0

    q = [ (0,0) ]

    while q:
        c,v = heapq.heappop(q)
        if d[v] != c:
            continue
        vx,vy = xy[v]

        for nex in range(N):
            nx,ny = xy[nex]
            ln = (abs(nx-vx)+abs(ny-vy)+P-1) // P + d[v] - 1

            if nex != v and d[nex] > ln:
                d[nex] = ln
                heapq.heappush(q,(ln,nex))
    
    # print (l,r,d)
    if d[-1] <= K:
        r = P
    else:
        l = P

print (r)
0