結果

問題 No.2354 Poor Sight in Winter
ユーザー Navier_BoltzmannNavier_Boltzmann
提出日時 2023-06-16 22:25:53
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,066 bytes
コンパイル時間 614 ms
コンパイル使用メモリ 87,128 KB
実行使用メモリ 91,264 KB
最終ジャッジ日時 2023-09-06 20:37:48
合計ジャッジ時間 7,189 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 92 ms
72,952 KB
testcase_01 AC 90 ms
72,712 KB
testcase_02 AC 93 ms
73,160 KB
testcase_03 WA -
testcase_04 AC 92 ms
73,112 KB
testcase_05 WA -
testcase_06 AC 89 ms
73,084 KB
testcase_07 AC 90 ms
72,960 KB
testcase_08 AC 90 ms
72,944 KB
testcase_09 AC 98 ms
77,604 KB
testcase_10 AC 95 ms
77,852 KB
testcase_11 AC 270 ms
89,816 KB
testcase_12 AC 257 ms
89,956 KB
testcase_13 AC 366 ms
91,264 KB
testcase_14 AC 405 ms
90,764 KB
testcase_15 AC 333 ms
90,424 KB
testcase_16 AC 346 ms
90,836 KB
testcase_17 AC 340 ms
90,036 KB
testcase_18 AC 250 ms
84,088 KB
testcase_19 AC 320 ms
87,920 KB
testcase_20 AC 259 ms
85,240 KB
testcase_21 AC 156 ms
80,524 KB
testcase_22 AC 227 ms
83,664 KB
testcase_23 AC 227 ms
83,804 KB
testcase_24 AC 280 ms
87,388 KB
testcase_25 WA -
testcase_26 AC 188 ms
81,944 KB
testcase_27 AC 119 ms
78,596 KB
testcase_28 AC 143 ms
80,368 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
    
x = 1
y = 10**5
while y-x>1:
    mid = (y+x)//2
    if is_ok(mid):
        y = mid
    else:
        x = mid
print(y)
0