結果
| 問題 |
No.2354 Poor Sight in Winter
|
| コンテスト | |
| ユーザー |
ニックネーム
|
| 提出日時 | 2023-06-16 21:54:08 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 666 bytes |
| コンパイル時間 | 258 ms |
| コンパイル使用メモリ | 82,592 KB |
| 実行使用メモリ | 183,976 KB |
| 最終ジャッジ日時 | 2024-06-24 13:56:12 |
| 合計ジャッジ時間 | 21,595 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 21 TLE * 5 |
ソースコード
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)
ニックネーム