結果

問題 No.2354 Poor Sight in Winter
ユーザー ニックネームニックネーム
提出日時 2023-06-16 21:54:08
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 666 bytes
コンパイル時間 1,286 ms
コンパイル使用メモリ 86,908 KB
実行使用メモリ 185,792 KB
最終ジャッジ日時 2023-09-06 19:31:14
合計ジャッジ時間 26,300 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 77 ms
71,332 KB
testcase_01 AC 76 ms
71,216 KB
testcase_02 AC 77 ms
71,008 KB
testcase_03 AC 76 ms
71,260 KB
testcase_04 AC 77 ms
71,108 KB
testcase_05 AC 77 ms
71,332 KB
testcase_06 AC 75 ms
71,040 KB
testcase_07 AC 77 ms
71,288 KB
testcase_08 AC 74 ms
71,212 KB
testcase_09 AC 77 ms
71,236 KB
testcase_10 AC 98 ms
76,316 KB
testcase_11 AC 1,521 ms
149,364 KB
testcase_12 AC 1,069 ms
116,132 KB
testcase_13 TLE -
testcase_14 TLE -
testcase_15 TLE -
testcase_16 TLE -
testcase_17 TLE -
testcase_18 AC 793 ms
101,616 KB
testcase_19 AC 1,659 ms
136,864 KB
testcase_20 AC 932 ms
103,120 KB
testcase_21 AC 267 ms
79,772 KB
testcase_22 AC 558 ms
90,120 KB
testcase_23 AC 584 ms
89,772 KB
testcase_24 AC 1,376 ms
125,764 KB
testcase_25 AC 381 ms
82,064 KB
testcase_26 AC 376 ms
82,284 KB
testcase_27 AC 166 ms
78,044 KB
testcase_28 AC 241 ms
79,868 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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