結果

問題 No.2354 Poor Sight in Winter
ユーザー minimumminimum
提出日時 2023-06-16 22:44:09
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,654 ms / 2,000 ms
コード長 1,036 bytes
コンパイル時間 1,419 ms
コンパイル使用メモリ 86,948 KB
実行使用メモリ 78,696 KB
最終ジャッジ日時 2023-09-06 21:15:32
合計ジャッジ時間 12,773 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 67 ms
71,336 KB
testcase_01 AC 66 ms
71,296 KB
testcase_02 AC 65 ms
71,188 KB
testcase_03 AC 66 ms
71,360 KB
testcase_04 AC 66 ms
71,228 KB
testcase_05 AC 66 ms
71,256 KB
testcase_06 AC 64 ms
71,496 KB
testcase_07 AC 64 ms
71,208 KB
testcase_08 AC 68 ms
71,328 KB
testcase_09 AC 77 ms
75,680 KB
testcase_10 AC 79 ms
76,340 KB
testcase_11 AC 231 ms
77,652 KB
testcase_12 AC 216 ms
77,680 KB
testcase_13 AC 1,654 ms
78,276 KB
testcase_14 AC 1,274 ms
78,616 KB
testcase_15 AC 823 ms
78,044 KB
testcase_16 AC 1,022 ms
78,168 KB
testcase_17 AC 1,099 ms
78,696 KB
testcase_18 AC 411 ms
78,532 KB
testcase_19 AC 909 ms
78,268 KB
testcase_20 AC 452 ms
77,824 KB
testcase_21 AC 123 ms
77,696 KB
testcase_22 AC 225 ms
77,920 KB
testcase_23 AC 245 ms
77,824 KB
testcase_24 AC 564 ms
78,288 KB
testcase_25 AC 177 ms
77,756 KB
testcase_26 AC 161 ms
77,856 KB
testcase_27 AC 104 ms
77,576 KB
testcase_28 AC 116 ms
77,760 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from heapq import heappop, heappush
import sys
input = sys.stdin.readline
INF = 10 ** 18
C = 10 ** 7

def main():
    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 = 2 * 10 ** 5 + 10
    while hi - lo > 1:
        p = (hi + lo) // 2
        if solve(p):
            hi = p
        else:
            lo = p

    print(hi)

if __name__ == "__main__":
    main()
0