結果
問題 | No.2354 Poor Sight in Winter |
ユーザー |
![]() |
提出日時 | 2023-06-16 22:30:05 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 461 ms / 2,000 ms |
コード長 | 845 bytes |
コンパイル時間 | 170 ms |
コンパイル使用メモリ | 82,264 KB |
実行使用メモリ | 80,128 KB |
最終ジャッジ日時 | 2024-06-24 15:06:08 |
合計ジャッジ時間 | 6,571 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 26 |
ソースコード
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)