結果
| 問題 |
No.2354 Poor Sight in Winter
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2023-06-16 22:44:09 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 1,834 ms / 2,000 ms |
| コード長 | 1,036 bytes |
| コンパイル時間 | 295 ms |
| コンパイル使用メモリ | 82,048 KB |
| 実行使用メモリ | 76,908 KB |
| 最終ジャッジ日時 | 2024-06-24 15:36:16 |
| 合計ジャッジ時間 | 12,088 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 26 |
ソースコード
from heapq import heappop, heappush
import sys
input = sys.stdin.readline
INF = 10 ** 18
C = 10 ** 7
def main():
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)
dist = [INF] * (N + 2)
dist[0] = 0
while hq:
now = heappop(hq) % C
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 * C + i)
return dist[1] <= K
lo = 0
hi = 2 * 10 ** 5 + 10
while hi - lo > 1:
p = (hi + lo) // 2
if solve(p):
hi = p
else:
lo = p
print(hi)
if __name__ == "__main__":
main()