#include namespace { #pragma GCC diagnostic ignored "-Wunused-function" #include #pragma GCC diagnostic warning "-Wunused-function" using namespace std; using namespace atcoder; #define rep(i,n) for(int i = 0; i < (int)(n); i++) #define rrep(i,n) for(int i = (int)(n) - 1; i >= 0; i--) #define all(x) begin(x), end(x) #define rall(x) rbegin(x), rend(x) template bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } else return false; } template bool chmin(T& a, const T& b) { if (b < a) { a = b; return true; } else return false; } using ll = long long; using P = pair; using VI = vector; using VVI = vector; using VL = vector; using VVL = vector; template vector manhattan_dist_max(vector> ps) { T v1, v2, v3, v4; v1 = v3 = numeric_limits::max(); v2 = v4 = numeric_limits::min(); for(auto [x, y] : ps) { T s = x + y; T t = -x + y; chmin(v1, s); chmax(v2, s); chmin(v3, t); chmax(v4, t); } int n = ps.size(); vector res; res.reserve(n); for(auto [x, y] : ps) { T s = x + y; T t = -x + y; res.emplace_back(max({s - v1, v2 - s, t - v3, v4 - t})); } return res; } template vector manhattan_dist_min(const vector>& points) { const int n = points.size(); assert(n >= 2); struct S { int x, y, i; }; vector ps(n); for (int i = 0; i < n; i++) { auto [x, y] = points[i]; ps[i] = {x + y, -x + y, i}; } sort(ps.begin(), ps.end(), [](const S& p1, const S& p2) { return p1.x < p2.x; }); vector vals(n); for (int i = 0; i < n; i++) vals[i] = ps[i].y; sort(vals.begin(), vals.end()); vals.erase(unique(vals.begin(), vals.end()), vals.end()); const int sz = vals.size(); vector ls(n, -1), rs(n); auto dist = [&](const S& p1, const S& p2) { return max(abs(p1.x - p2.x), abs(p1.y - p2.y)); }; for (int i = 1; i < n; i++) rs[0] = rs[i] = dist(ps[0], ps[i]); vector> evs; fenwick_tree ft(sz); vector cnt(n); while(true) { evs.clear(); for (int i = 0; i < n; i++) if (rs[i] - ls[i] > 1) { T c = (rs[i] + ls[i]) / 2; assert(c >= 0); evs.emplace_back(ps[i].x - c, false, i); evs.emplace_back(ps[i].x + c, true, i); } if (evs.empty()) break; sort(evs.begin(), evs.end()); int ptr = 0; for (auto [x, t, i] : evs) { while(ptr < n && ((!t && ps[ptr].x < x) || (t && ps[ptr].x <= x))) { ft.add(lower_bound(vals.begin(), vals.end(), ps[ptr++].y) - vals.begin(), 1); } T c = (rs[i] + ls[i]) / 2; int l = lower_bound(vals.begin(), vals.end(), ps[i].y - c) - vals.begin(); int r = upper_bound(vals.begin(), vals.end(), ps[i].y + c) - vals.begin(); int sm = ft.sum(l, r); if (!t) { cnt[i] = sm; } else { assert(cnt[i] + 1 <= sm); (cnt[i] + 1 == sm ? ls[i] : rs[i]) = c; } } } vector res(n); for (int i = 0; i < n; i++) res[ps[i].i] = rs[i]; return res; } } int main() { ios::sync_with_stdio(false); cin.tie(0); int n; cin >> n; vector

xy(n); for(auto& [x, y] : xy) cin >> x >> y; VI mx = manhattan_dist_max(xy); VI mn = manhattan_dist_min(xy); int ans = 2001001001; rep(i, n) chmin(ans, mx[i] - mn[i]); cout << ans << '\n'; }