結果

問題 No.2354 Poor Sight in Winter
ユーザー ニックネームニックネーム
提出日時 2023-06-16 22:00:05
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 356 ms / 2,000 ms
コード長 776 bytes
コンパイル時間 386 ms
コンパイル使用メモリ 86,872 KB
実行使用メモリ 82,216 KB
最終ジャッジ日時 2023-09-06 19:45:27
合計ジャッジ時間 6,638 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 68 ms
71,328 KB
testcase_01 AC 64 ms
71,424 KB
testcase_02 AC 66 ms
71,060 KB
testcase_03 AC 73 ms
71,400 KB
testcase_04 AC 72 ms
71,412 KB
testcase_05 AC 67 ms
71,264 KB
testcase_06 AC 66 ms
71,260 KB
testcase_07 AC 66 ms
71,376 KB
testcase_08 AC 69 ms
71,508 KB
testcase_09 AC 69 ms
71,060 KB
testcase_10 AC 73 ms
76,176 KB
testcase_11 AC 228 ms
81,484 KB
testcase_12 AC 174 ms
80,636 KB
testcase_13 AC 350 ms
82,184 KB
testcase_14 AC 352 ms
81,700 KB
testcase_15 AC 331 ms
81,716 KB
testcase_16 AC 313 ms
81,848 KB
testcase_17 AC 356 ms
82,216 KB
testcase_18 AC 236 ms
80,564 KB
testcase_19 AC 322 ms
81,552 KB
testcase_20 AC 252 ms
80,360 KB
testcase_21 AC 143 ms
78,444 KB
testcase_22 AC 218 ms
79,892 KB
testcase_23 AC 214 ms
79,744 KB
testcase_24 AC 262 ms
80,632 KB
testcase_25 AC 158 ms
78,620 KB
testcase_26 AC 175 ms
78,336 KB
testcase_27 AC 105 ms
77,776 KB
testcase_28 AC 132 ms
78,412 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 = [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)
0