結果
問題 | 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 sysfrom sys import stdinimport mathimport heapqN,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 += 2l = 0r = abs(sx-gx) + abs(sy-gy) + 1while r-l != 1:P = (l+r)//2d = [float("inf")] * Nd[0] = 0q = [ (0,0) ]while q:c,v = heapq.heappop(q)if d[v] != c:continuevx,vy = xy[v]for nex in range(N):nx,ny = xy[nex]ln = (abs(nx-vx)+abs(ny-vy)+P-1) // P + d[v] - 1if nex != v and d[nex] > ln:d[nex] = lnheapq.heappush(q,(ln,nex))# print (l,r,d)if d[-1] <= K:r = Pelse:l = Pprint (r)