#include using namespace std; using ll = long long; template istream& operator >> (istream& is, vector& vec) { for(T& x : vec) is >> x; return is; } template ostream& operator << (ostream& os, const vector& vec) { if(vec.empty()) return os; os << vec[0]; for(auto it = vec.begin(); ++it != vec.end(); ) os << ' ' << *it; return os; } template using rpriority_queue = priority_queue, greater>; int main(){ ios::sync_with_stdio(false); cin.tie(0); int n, k, x, y, gx, gy, x2, y2, d; cin >> n >> k; vector> a(n + 2); cin >> x >> y; a[n] = {x, y}; cin >> gx >> gy; a[n + 1] = {gx, gy}; for(int i = 0; i < n; i++){ cin >> x >> y; a[i] = {x, y}; } int ng = -1, ok = 1000000000, mid; while(ng + 1 < ok){ mid = (ng + ok) / 2; vector>> g(n + 2); int L = mid; for(int i = 0; i < n + 2; i++){ tie(x, y) = a[i]; for(int j = i + 1; j < n + 2; j++){ tie(x2, y2) = a[j]; d = abs(x - x2) + abs(y - y2) - (i < n || j < n ? mid : 0); if(d <= 0){ g[i].emplace_back(j, 0); g[j].emplace_back(i, 0); }else if(mid >= 1){ g[i].emplace_back(j, (d + mid - 1) / mid); g[j].emplace_back(i, (d + mid - 1) / mid); }else{ g[i].emplace_back(j, d); g[j].emplace_back(i, d); } } } vector dp(n + 2, 1 << 30); rpriority_queue> pq; pq.emplace(0, n); dp[n] = 0; while(!pq.empty()){ int d, v; tie(d, v) = pq.top(); pq.pop(); if(d > dp[v]) continue; for(auto &&pa : g[v]){ int w, u; tie(u, w) = pa; if(d + w >= dp[u]) continue; dp[u] = d + w; pq.emplace(d + w, u); } } (dp[n + 1] <= k ? ok : ng) = mid; } cout << ok << '\n'; }