結果
問題 | No.2354 Poor Sight in Winter |
ユーザー |
|
提出日時 | 2023-06-16 22:35:47 |
言語 | PyPy3 (7.3.15) |
結果 |
TLE
(最新)
AC
(最初)
|
実行時間 | - |
コード長 | 806 bytes |
コンパイル時間 | 234 ms |
コンパイル使用メモリ | 82,320 KB |
実行使用メモリ | 79,088 KB |
最終ジャッジ日時 | 2024-06-24 15:16:47 |
合計ジャッジ時間 | 14,231 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 25 TLE * 1 |
ソースコード
from heapq import heappop, heappush INF = 10 ** 18 N, K = map(int, input().split()) sx, sy, gx, gy = map(int, input().split()) X, Y = [sx, gx], [sy, gy] for _ in range(N): x, y = map(int, input().split()) X.append(x) Y.append(y) def solve(P): hq = [] heappush(hq, (0, 0)) dist = [INF] * (N + 2) dist[0] = 0 while hq: _, now = heappop(hq) for i in range(N + 2): if now == i: continue ndist = dist[now] + (abs(X[i] - X[now]) + abs(Y[i] - Y[now]) - 1) // P if dist[i] > ndist: dist[i] = ndist heappush(hq, (ndist, i)) return dist[1] <= K lo = 0 hi = 10 ** 6 while hi - lo > 1: p = (hi + lo) // 2 if solve(p): hi = p else: lo = p print(hi)