#pragma GCC optimize("Ofast,no-stack-protector") #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2") #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; typedef long long LL; typedef unsigned long long ULL; #define MEM(a,b) memset((a),(b),sizeof(a)) const LL INF = 1e9 + 7; const int N = 5e2 + 10; int a[N][N]; int d[N][N]; pair vp[N]; void floyd(int n) { for (int k = 0; k <= n; k++) { for (int i = 0; i <= n; i++) { for (int j = 0; j <= n; j++) a[i][j] = min(a[i][j], a[i][k] + a[k][j]); } } } inline int dis(int i, int j) { return abs(vp[i].first - vp[j].first) + abs(vp[i].second - vp[j].second); } int main() { //freopen("input.txt", "r", stdin); //freopen("output.txt", "w", stdout); int n, k; scanf("%d%d", &n, &k); scanf("%d%d%d%d", &vp[0].first, &vp[0].second, &vp[n + 1].first, &vp[n + 1].second); for (int i = 1; i <= n; i++) scanf("%d%d", &vp[i].first, &vp[i].second); n++; for (int i = 0; i <= n; i++) { for (int j = 0; j <= n; j++) d[i][j] = dis(i, j); } int l = 1, r = dis(0, n); int ans = r; while (l <= r) { int mid = (l + r) / 2; for (int i = 0; i <= n; i++) { for (int j = 0; j <= n; j++) { int d = ::d[i][j] - mid; d = max(0, d); a[i][j] = (d + mid - 1) / (mid); } } floyd(n); if (a[0][n] <= k) ans = mid, r = mid - 1; else l = mid + 1; } printf("%d\n", ans); return 0; }