結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 61 ms
71,212 KB
testcase_01 AC 61 ms
71,416 KB
testcase_02 AC 61 ms
71,180 KB
testcase_03 AC 65 ms
71,428 KB
testcase_04 AC 63 ms
71,504 KB
testcase_05 AC 60 ms
71,348 KB
testcase_06 AC 60 ms
71,320 KB
testcase_07 AC 63 ms
71,072 KB
testcase_08 AC 62 ms
71,372 KB
testcase_09 AC 70 ms
75,788 KB
testcase_10 AC 74 ms
76,244 KB
testcase_11 AC 141 ms
77,084 KB
testcase_12 AC 272 ms
77,448 KB
testcase_13 AC 271 ms
78,256 KB
testcase_14 AC 347 ms
77,724 KB
testcase_15 AC 208 ms
78,468 KB
testcase_16 AC 348 ms
78,024 KB
testcase_17 AC 311 ms
78,648 KB
testcase_18 AC 187 ms
77,764 KB
testcase_19 AC 210 ms
78,536 KB
testcase_20 AC 148 ms
77,696 KB
testcase_21 AC 124 ms
77,904 KB
testcase_22 AC 171 ms
78,092 KB
testcase_23 AC 147 ms
77,604 KB
testcase_24 AC 214 ms
78,196 KB
testcase_25 AC 120 ms
77,108 KB
testcase_26 AC 136 ms
77,884 KB
testcase_27 AC 90 ms
77,072 KB
testcase_28 AC 121 ms
77,512 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline

N, K = map(int, input().split())
N += 2
X, Y = [0] * N, [0] * N
X[0], Y[0], X[-1], Y[-1] = map(int, input().split())
for i in range(1, N-1):
    X[i], Y[i] = map(int, input().split())
    
    
def check(P):
    inf = 10 ** 18
    dist = [inf] * N
    seen = [0] * N
    dist[0] = 0
    while True:
        mi = inf
        ind = -1
        for i in range(N):
            if seen[i]:
                continue
            if dist[i] < mi:
                ind = i
                mi = dist[i]
        if ind == -1:
            break
        seen[ind] = 1
        for i in range(N):
            d = abs(X[ind] - X[i]) + abs(Y[ind] - Y[i])
            cost = max(0, (d + P - 1)//P - 1)
            dist[i] = min(dist[i], dist[ind] + cost)
        
        if seen[-1]:
            return dist[-1] <= K
        
    return False
                

yes = 2 * 10 ** 5 + 5
no = 0
while yes - no != 1:
    mid = (yes + no)//2
    if check(mid):
        yes = mid
    else:
        no = mid
print(yes)
0