結果

問題 No.2354 Poor Sight in Winter
ユーザー とりゐとりゐ
提出日時 2023-06-16 22:33:09
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 552 ms / 2,000 ms
コード長 739 bytes
コンパイル時間 502 ms
コンパイル使用メモリ 86,804 KB
実行使用メモリ 82,832 KB
最終ジャッジ日時 2023-09-06 20:51:39
合計ジャッジ時間 9,044 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 67 ms
71,260 KB
testcase_01 AC 65 ms
71,404 KB
testcase_02 AC 68 ms
71,424 KB
testcase_03 AC 68 ms
71,532 KB
testcase_04 AC 67 ms
71,280 KB
testcase_05 AC 68 ms
70,976 KB
testcase_06 AC 67 ms
71,292 KB
testcase_07 AC 67 ms
71,428 KB
testcase_08 AC 67 ms
71,220 KB
testcase_09 AC 75 ms
75,964 KB
testcase_10 AC 80 ms
76,048 KB
testcase_11 AC 330 ms
79,772 KB
testcase_12 AC 348 ms
79,744 KB
testcase_13 AC 552 ms
82,832 KB
testcase_14 AC 545 ms
82,228 KB
testcase_15 AC 543 ms
81,972 KB
testcase_16 AC 543 ms
81,360 KB
testcase_17 AC 542 ms
82,220 KB
testcase_18 AC 345 ms
81,236 KB
testcase_19 AC 456 ms
81,160 KB
testcase_20 AC 361 ms
79,924 KB
testcase_21 AC 207 ms
79,344 KB
testcase_22 AC 311 ms
80,204 KB
testcase_23 AC 302 ms
80,576 KB
testcase_24 AC 419 ms
80,904 KB
testcase_25 AC 231 ms
79,660 KB
testcase_26 AC 223 ms
79,508 KB
testcase_27 AC 119 ms
77,888 KB
testcase_28 AC 176 ms
79,048 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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)
0