結果
| 問題 |
No.2354 Poor Sight in Winter
|
| コンテスト | |
| ユーザー |
とりゐ
|
| 提出日時 | 2023-06-16 22:33:09 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 588 ms / 2,000 ms |
| コード長 | 739 bytes |
| コンパイル時間 | 385 ms |
| コンパイル使用メモリ | 82,408 KB |
| 実行使用メモリ | 80,156 KB |
| 最終ジャッジ日時 | 2024-06-24 15:11:46 |
| 合計ジャッジ時間 | 8,666 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 26 |
ソースコード
n,k=map(int,input().split())
sx,sy,gx,gy=map(int,input().split())
xy=[]
xy.append((sx,sy))
xy.append((gx,gy))
for i in range(n):
x,y=map(int,input().split())
xy.append((x,y))
def dist(i,j,s):
xi,yi=xy[i]
xj,yj=xy[j]
d=abs(xi-xj)+abs(yi-yj)
return (d+s-1)//s-1
from heapq import heappush, heappop
n+=2
inf=1<<60
def calc(mid):
D=[inf]*n
D[0]=0
seen=[False]*n
hq=[(0,0)]
while hq:
w,v=heappop(hq)
if D[v]<w:
continue
seen[v]=True
for u in range(n):
res=w+dist(u,v,mid)
if seen[u]==False and res<D[u]:
D[u]=res
heappush(hq,(res,u))
return D[1]
ng,ok=0,3*10**5
while abs(ok-ng)>1:
mid=(ok+ng)//2
if calc(mid)<=k:
ok=mid
else:
ng=mid
print(ok)
とりゐ