#include #include using namespace std; using ll = long long; #define REP(i,n) for(int i=0;i void chmin(T& a, T b) { a = min(a, b); } template void chmax(T& a, T b) { a = max(a, b); } #define PR(x) cerr << #x << "=" << x << endl using i128 = __int128_t; struct Edge { int to; long long cost; int i = 0; }; int main() { int n, k; cin >> n >> k; vector> G(n+2); ll sx, sy, gx, gy; cin >> sx >> sy >> gx >> gy; G[n].push_back({n+1,abs(gx - sx) + abs(gy - sy)}); vector x(n), y(n); REP(i, n) { cin >> x[i] >> y[i]; ll ds = abs(x[i] - sx) + abs(y[i] - sy); ll dg = abs(x[i] - gx) + abs(y[i] - gy); G[n].push_back({i,ds}); G[i].push_back({n+1,dg}); } REP(i, n) { REP(j, n) { if(i == j) continue; ll d = abs(x[i] - x[j]) + abs(y[i] - y[j]); G[i].push_back({j,d}); } } ll ok = 1e6; ll ng = 0; while(ok - ng > 1) { ll ch = (ok + ng) / 2; priority_queue> pq; pq.push({k, n}); vector max_k(n+2, -INF); max_k[n] = k; while(pq.size()) { auto [nk, now] = pq.top(); pq.pop(); if(max_k[now] != nk) continue; for(auto e: G[now]) { ll newc = nk - (e.cost-1) / ch; if(max_k[e.to] < newc) { max_k[e.to] = newc; pq.push({newc, e.to}); } } } if(max_k[n+1] < 0) { ng = ch; } else { ok = ch; } } cout << ok; return 0; }