#include #include #include #include using namespace std; typedef long long ll; void dijkstra(vector>> &graph, ll v, vector &dist, ll P){ priority_queue, vector>, greater>> pque; pque.push(pair(0, v)); dist[v] = 0; while(pque.size()){ pair p = pque.top(); pque.pop(); if (dist[p.second] != p.first){ continue; } for (auto x: graph[p.second]){ if (dist[x.first] > dist[p.second] + (x.second + P - 1) / P - 1){ dist[x.first] = dist[p.second] + (x.second + P - 1) / P - 1; pque.push(pair(dist[x.first], x.first)); } } } } int main(){ ll N, K; cin >> N >> K; ll sx, sy, gx, gy; cin >> sx >> sy >> gx >> gy; vector x(N); vector y(N); for (ll i = 0; i < N; i++){ cin >> x[i] >> y[i]; } vector>> graph(N + 2, vector>(0)); for (ll i = 0; i < N; i++){ for (ll j = 0; j < N; j++){ if (i != j){ graph[i].push_back(pair(j, abs(x[i] - x[j]) + abs(y[i] - y[j]))); } } } for (ll i = 0; i < N; i++){ graph[i].push_back(pair(N, abs(x[i] - sx) + abs(y[i] - sy))); graph[N].push_back(pair(i, abs(x[i] - sx) + abs(y[i] - sy))); } for (ll i = 0; i < N; i++){ graph[i].push_back(pair(N + 1, abs(x[i] - gx) + abs(y[i] - gy))); graph[N + 1].push_back(pair(i, abs(x[i] - gx) + abs(y[i] - gy))); } graph[N].push_back(pair(N + 1, abs(sx - gx) + abs(sy - gy))); graph[N + 1].push_back(pair(N, abs(sx - gx) + abs(sy - gy))); ll INF = 10000000; ll ng = 0; ll ok = 200000; while (ok - ng > 1){ ll center = (ng + ok) / 2; vector dist(N + 2, INF); dijkstra(graph, N, dist, center); if (dist[N + 1] <= K){ ok = center; } else{ ng = center; } } cout << ok << endl; }