#include using namespace std; using ll = long long; using P = pair; #define fix(x) fixed << setprecision(x) #define asc(x) x, vector, greater #define rep(i, n) for(ll i = 0; i < n; i++) #define all(x) (x).begin(),(x).end() templatebool chmin(T&a, const T&b){if(a>b){a=b;return 1;}return 0;} templatebool chmax(T&a, const T&b){if(a> n >> k; vector x(n+2), y(n+2); rep(i,n+2) cin >> x[i] >> y[i]; int ng = 0, ok = abs(x[0]-x[1]) + abs(y[0]-y[1]); vector> di(n+2,vector(n+2,0)); rep(i,n+2)rep(j,i) di[i][j] = di[j][i] = abs(x[i]-x[j])+abs(y[i]-y[j]); while(ok-ng>1){ int md = (ok+ng)/2; vector dist(n+2,INF); dist[0] = 0; priority_queue pq; pq.push({0,0}); while(pq.size()){ int now, d; tie(d,now) = pq.top(); if(now==1) break; pq.pop(); if(dist[now]!=d) continue; rep(i,n+2){ if(chmin(dist[i], dist[now]+(di[now][i]-1)/md)) pq.push({dist[i],i}); } } if(dist[1]<=k) ok = md; else ng = md; } cout << ok << '\n'; return 0; }