結果
| 問題 | No.2354 Poor Sight in Winter |
| コンテスト | |
| ユーザー |
ニックネーム
|
| 提出日時 | 2023-06-16 21:54:08 |
| 言語 | PyPy3 (7.3.17) |
| 結果 |
AC
|
| 実行時間 | 1,579 ms / 2,000 ms |
| + 382µs | |
| コード長 | 666 bytes |
| 記録 | |
| コンパイル時間 | 251 ms |
| コンパイル使用メモリ | 95,980 KB |
| 実行使用メモリ | 186,892 KB |
| 最終ジャッジ日時 | 2026-07-29 03:53:59 |
| 合計ジャッジ時間 | 16,626 ms |
|
ジャッジサーバーID (参考情報) |
judge1_0 / judge3_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 26 |
ソースコード
from heapq import heappop,heappush
n,k = map(int,input().split())
sx,sy,gx,gy = map(int,input().split())
xy = [(sx,sy)]+[tuple(map(int,input().split())) for _ in range(n)]+[(gx,gy)]
dist = [[0]*(n+2) for _ in range(n+2)]
for i,(ix,iy) in enumerate(xy):
for j,(jx,jy) in enumerate(xy): dist[i][j] = abs(ix-jx)+abs(iy-jy)
ng = 0; ok = dist[0][n+1]
while ok-ng>1:
mid = (ng+ok)//2
d = [10**9]*(n+2); hq = [(0,0)]
while hq:
v,p = heappop(hq)
if d[p]!=10**9: continue
d[p] = v
for i in range(n+2):
if d[i]==10**9: heappush(hq,(d[p]+(dist[p][i]-1)//mid,i))
if d[n+1]<=k: ok = mid
else: ng = mid
print(ok)
ニックネーム