#include #include #include #include #include #include #include #include #include #include #include #include #include #define debug_value(x) cerr << "line" << __LINE__ << ":<" << __func__ << ">:" << #x << "=" << x << endl; #define debug(x) cerr << "line" << __LINE__ << ":<" << __func__ << ">:" << x << endl; template inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; } template inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; } using namespace std; typedef long long ll; template vector> vec2d(int n, int m, T v){ return vector>(n, vector(m, v)); } template vector>> vec3d(int n, int m, int k, T v){ return vector>>(n, vector>(m, vector(k, v))); } template void print_vector(vector v, char delimiter=' '){ if(v.empty()) { cout << endl; return; } for(int i = 0; i+1 < v.size(); i++) cout << v[i] << delimiter; cout << v.back() << endl; } // calc ceil(a/b) template T ceil_div(T a, T b){ return (a+b-1)/b; } const ll inf = 1e18; using P = pair; int main(){ ios::sync_with_stdio(false); cin.tie(0); cout << setprecision(10) << fixed; int n, k; cin >> n >> k; ll sx, sy, gx, gy; cin >> sx >> sy >> gx >> gy; vector

ps = {{sx, sy}}; for(int i = 0; i < n; i++){ ll x, y; cin >> x >> y; ps.push_back({x, y}); } ps.push_back({gx, gy}); n = ps.size(); auto d = vec2d(n, n, 0ll); for(int i = 0; i < n; i++){ for(int j = 0; j < n; j++){ auto [xi, yi] = ps[i]; auto [xj, yj] = ps[j]; d[i][j] = abs(xi-xj)+abs(yi-yj); } } auto f = [&](ll x){ vector dist(n, inf); priority_queue, greater

> que; auto set_dist = [&](int v, ll d){ if(chmin(dist[v], d)) que.push({d, v}); }; set_dist(0, 0); while(!que.empty()){ auto [dd, v] = que.top(); que.pop(); if(dd != dist[v]) continue; for(int i = 0; i < n; i++){ if(i == v) continue; ll cnt = ceil_div(d[v][i], x)-1; set_dist(i, dd+cnt); } } return dist[n-1] <= k; }; ll l = 0, r = inf; while(r-l > 1){ ll x = (l+r)/2; if(f(x)) { r = x; } else l = x; } cout << r << endl; }