typedef long long ll; typedef long double ld; #include using namespace std; #define int long long ll isqrt(ll N){ ll sqrtN=sqrt(N)-1; while(sqrtN+1<=N/(sqrtN+1))sqrtN++; return sqrtN; } // Union-Find struct UnionFind { // core member vector par; // constructor UnionFind() { } UnionFind(int n) : par(n, -1) { } void init(int n) { par.assign(n, -1); } // core methods int root(int x) { if (par[x] < 0) return x; else return par[x] = root(par[x]); } bool same(int x, int y) { return root(x) == root(y); } bool merge(int x, int y) { x = root(x), y = root(y); if (x == y) return false; if (par[x] > par[y]) swap(x, y); // merge technique par[x] += par[y]; par[y] = x; return true; } int size(int x) { return -par[root(x)]; } // debug friend ostream& operator << (ostream &s, UnionFind uf) { map> groups; for (int i = 0; i < uf.par.size(); ++i) { int r = uf.root(i); groups[r].push_back(i); } for (const auto &it : groups) { s << "group: "; for (auto v : it.second) s << v << " "; s << endl; } return s; } }; signed main(){ ll n,k; std::cin >> n>>k; pair s,g; std::cin >> s.first>>s.second>>g.first>>g.second; vector x(n),y(n); for (int i = 0; i < n; i++) { std::cin >> x[i]>>y[i]; } ll r = 2*1e7; ll l = 0; while(r-l>1){ ll m =(r+l)/2; // std::cout << l<<" "<> dis(n+2,vector(n+2,1e10)); for (int i = 0; i < n; i++) { for (int j = i+1; j < n; j++) { if(uf.same(i,j))dis[uf.root(i)][uf.root(i)]=0; if(!uf.same(i,j)){ ll d = abs(x[i]-x[j])+abs(y[i]-y[j]); dis[uf.root(i)][uf.root(j)] = min(dis[uf.root(i)][uf.root(j)], (d+m-1)/(m)-1); dis[uf.root(j)][uf.root(i)] = min(dis[uf.root(j)][uf.root(i)], (d+m-1)/(m)-1); } } } for (int i = 0; i < n; i++) { if(!uf.same(i,n)){ ll d = abs(x[i]-s.first)+abs(y[i]-s.second); dis[uf.root(i)][uf.root(n)] = min(dis[uf.root(i)][uf.root(n)], (d+m-1)/(m)-1); dis[uf.root(n)][uf.root(i)] = min(dis[uf.root(n)][uf.root(i)], (d+m-1)/(m)-1); } if(!uf.same(i,n+1)){ ll d = abs(x[i]-g.first)+abs(y[i]-g.second); dis[uf.root(i)][uf.root(n+1)] = min(dis[uf.root(i)][uf.root(n+1)], (d+m-1)/(m)-1); dis[uf.root(n+1)][uf.root(i)] = min(dis[uf.root(n+1)][uf.root(i)], (d+m-1)/(m)-1); } } set uni; for (int i = 0; i < n; i++) { uni.insert(uf.root(i)); } uni.insert(uf.root(n)); uni.insert(uf.root(n+1)); vector dd(n+2,1e10); dd[uf.root(n)]=0; using P = pair; priority_queue,greater

> pq; pq.push({0, uf.root(n)}); while(!pq.empty()){ auto [dist, pos] = pq.top();pq.pop(); if(dist>dd[pos])continue; for (auto e : uni) { if(e==pos)continue; if(dd[e]>dist+dis[pos][e]){ dd[e] = dist+dis[pos][e]; pq.push({dd[e], e}); } } } if(dd[uf.root(n+1)]<=k){ r = m; }else{ l = m; } } std::cout << r << std::endl; }