結果

問題 No.2354 Poor Sight in Winter
ユーザー yabityabit
提出日時 2023-07-05 14:13:39
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,000 bytes
コンパイル時間 493 ms
コンパイル使用メモリ 87,084 KB
実行使用メモリ 265,760 KB
最終ジャッジ日時 2023-09-26 14:05:58
合計ジャッジ時間 5,946 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 78 ms
75,740 KB
testcase_01 AC 81 ms
71,368 KB
testcase_02 AC 81 ms
71,416 KB
testcase_03 WA -
testcase_04 AC 79 ms
71,204 KB
testcase_05 WA -
testcase_06 AC 79 ms
71,524 KB
testcase_07 AC 80 ms
71,320 KB
testcase_08 AC 78 ms
71,492 KB
testcase_09 AC 101 ms
76,684 KB
testcase_10 AC 106 ms
76,492 KB
testcase_11 TLE -
testcase_12 TLE -
testcase_13 TLE -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

import heapq
N,K = map(int, input().split())
sx, sy, gx, gy = map(int, input().split())
X = [sx, gx]
Y = [sy, gy]
for i in range(N):
    x,y = map(int, input().split())
    X.append(x)
    Y.append(y)

def solve(P):
    G = [[] for _ in range(N+2)]
    for i in range(N+2):
        for j in range(N+2):
            if i == j:
                continue
            kyori = abs(X[i]-X[j]) + abs(Y[i]-Y[j])
            di = kyori//P
            if kyori % P == 0:
                di -= 1
            G[i].append((j, di))
    dist = [-1]*(N+2)
    que = [(0,0)]
    heapq.heapify(que)
    while que:
        d, v = heapq.heappop(que)
        if dist[v] > -1:
            continue
        dist[v] = d
        for u,e in G[v]:
            if dist[u] > -1:
                continue
            heapq.heappush(que, (d+e, u))
    # print(P, G, dist)
    return dist[1] <= K

ng,ok = 1, 2*10**5+1
while ok-ng > 1:
    mid = (ng + ok) // 2
    if solve(mid):
        ok = mid
    else:
        ng = mid
print(ok)
0