結果

問題 No.2354 Poor Sight in Winter
ユーザー Navier_BoltzmannNavier_Boltzmann
提出日時 2023-06-17 01:03:48
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 500 ms / 2,000 ms
コード長 1,092 bytes
コンパイル時間 696 ms
コンパイル使用メモリ 87,252 KB
実行使用メモリ 92,540 KB
最終ジャッジ日時 2023-09-06 23:56:31
合計ジャッジ時間 8,789 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 101 ms
73,144 KB
testcase_01 AC 98 ms
72,980 KB
testcase_02 AC 96 ms
72,852 KB
testcase_03 AC 98 ms
73,048 KB
testcase_04 AC 100 ms
72,888 KB
testcase_05 AC 100 ms
72,956 KB
testcase_06 AC 101 ms
73,020 KB
testcase_07 AC 102 ms
72,796 KB
testcase_08 AC 101 ms
73,064 KB
testcase_09 AC 110 ms
77,824 KB
testcase_10 AC 110 ms
77,776 KB
testcase_11 AC 358 ms
90,264 KB
testcase_12 AC 387 ms
91,824 KB
testcase_13 AC 485 ms
92,540 KB
testcase_14 AC 500 ms
91,324 KB
testcase_15 AC 442 ms
91,500 KB
testcase_16 AC 446 ms
90,912 KB
testcase_17 AC 442 ms
91,500 KB
testcase_18 AC 310 ms
84,488 KB
testcase_19 AC 405 ms
87,784 KB
testcase_20 AC 338 ms
85,484 KB
testcase_21 AC 194 ms
81,412 KB
testcase_22 AC 284 ms
83,792 KB
testcase_23 AC 276 ms
83,868 KB
testcase_24 AC 353 ms
86,712 KB
testcase_25 AC 145 ms
80,968 KB
testcase_26 AC 219 ms
81,900 KB
testcase_27 AC 144 ms
80,292 KB
testcase_28 AC 173 ms
81,256 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import *
from itertools import *
from functools import *
from heapq import *
import sys,math
input = sys.stdin.readline

N,K = map(int,input().split())
sx,sy,gx,gy = map(int,input().split())
xy = [tuple(map(int,input().split())) for _ in range(N)]
xy = [(sx,sy)] + xy + [(gx,gy)]
e = [[] for _ in range(N+2)]
for i in range(N+1):
    xi,yi = xy[i]
    for j in range(i+1,N+2):
        xj,yj = xy[j]
        d = abs(xi-xj)+abs(yi-yj)
        e[i].append((j,d))
        e[j].append((i,d))
INF = (1<<30)
def dijkstra(s,e,k):
    
    N = len(e)
    dist = [INF]*N
    dist[s]=0
    h = []
    heappush(h,(0,s))
    while h:
        nw,v = heappop(h)
        if dist[v]!=nw:
            continue
        for iv,ic in e[v]:
            nc = (ic-1)//k + nw
            if nc < dist[iv]:
                dist[iv] = nc
                heappush(h,(nc,iv))
    return dist
    
    
def is_ok(k):
    
    return dijkstra(0,e,k)[N+1]<=K
if is_ok(1):
	print(1)
	exit()
x = 1
y = 10**7
while y-x>1:
    mid = (y+x)//2
    if is_ok(mid):
        y = mid
    else:
        x = mid
print(y)
0