結果
| 問題 | No.2354 Poor Sight in Winter |
| コンテスト | |
| ユーザー |
ニックネーム
|
| 提出日時 | 2023-06-16 22:00:05 |
| 言語 | PyPy3 (7.3.17) |
| 結果 |
AC
|
| 実行時間 | 202 ms / 2,000 ms |
| コード長 | 776 bytes |
| 記録 | |
| コンパイル時間 | 428 ms |
| コンパイル使用メモリ | 85,772 KB |
| 実行使用メモリ | 85,764 KB |
| 最終ジャッジ日時 | 2026-03-10 17:33:40 |
| 合計ジャッジ時間 | 3,987 ms |
|
ジャッジサーバーID (参考情報) |
judge3_1 / judge1_1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| 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 = [0]+[10**9]*(n+1); f = [False]*(n+2); hq = [(0,0)]
while hq:
_,p = heappop(hq)
if f[p]: continue
f[p] = True
for i in range(n+2):
if p!=i and d[i]>d[p]+(dist[p][i]-1)//mid:
d[i] = d[p]+(dist[p][i]-1)//mid
heappush(hq,(d[p]+(dist[p][i]-1)//mid,i))
if d[n+1]<=k: ok = mid
else: ng = mid
print(ok)
ニックネーム