結果

問題 No.2354 Poor Sight in Winter
ユーザー shogo314shogo314
提出日時 2023-06-17 10:49:14
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 633 ms / 2,000 ms
コード長 859 bytes
コンパイル時間 467 ms
コンパイル使用メモリ 87,096 KB
実行使用メモリ 82,876 KB
最終ジャッジ日時 2023-09-07 08:07:03
合計ジャッジ時間 10,622 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 81 ms
71,164 KB
testcase_01 AC 80 ms
71,260 KB
testcase_02 AC 81 ms
71,392 KB
testcase_03 AC 82 ms
71,352 KB
testcase_04 AC 79 ms
71,148 KB
testcase_05 AC 80 ms
71,196 KB
testcase_06 AC 80 ms
71,432 KB
testcase_07 AC 79 ms
71,276 KB
testcase_08 AC 81 ms
70,900 KB
testcase_09 AC 91 ms
76,292 KB
testcase_10 AC 89 ms
76,024 KB
testcase_11 AC 366 ms
80,800 KB
testcase_12 AC 459 ms
81,732 KB
testcase_13 AC 616 ms
82,276 KB
testcase_14 AC 625 ms
82,692 KB
testcase_15 AC 633 ms
82,248 KB
testcase_16 AC 594 ms
82,108 KB
testcase_17 AC 628 ms
82,876 KB
testcase_18 AC 404 ms
80,708 KB
testcase_19 AC 539 ms
81,828 KB
testcase_20 AC 419 ms
81,348 KB
testcase_21 AC 230 ms
79,820 KB
testcase_22 AC 359 ms
80,456 KB
testcase_23 AC 346 ms
80,732 KB
testcase_24 AC 497 ms
82,156 KB
testcase_25 AC 282 ms
80,400 KB
testcase_26 AC 299 ms
80,988 KB
testcase_27 AC 153 ms
77,620 KB
testcase_28 AC 216 ms
79,940 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import heapq
N, K = map(int, input().split())
sx, sy, gx, gy = map(int, input().split())
xy = [(sx, sy), (gx, gy)]+[tuple(map(int, input().split())) for i in range(N)]
N += 2
ans_min = 0
ans_max = 2*10**5


def dis(i, j):
    return abs(xy[i][0]-xy[j][0])+abs(xy[i][1]-xy[j][1])


while ans_max-ans_min > 1:
    ans_mid = (ans_max+ans_min)//2
    inf = -1
    f = [False for i in range(N)]
    tbl = [2*10**5 for i in range(N)]
    hq = [(0, 0)]
    while hq:
        c, u = heapq.heappop(hq)
        if f[u]:
            continue
        f[u] = True
        for v in range(N):
            if f[v]:
                continue
            d = c+(dis(u, v)-1)//ans_mid
            if d < tbl[v]:
                tbl[v] = d
                heapq.heappush(hq, (d, v))
    if tbl[1] <= K:
        ans_max = ans_mid
    else:
        ans_min = ans_mid
print(ans_max)
0