#define _USE_MATH_DEFINES #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; typedef pair i_i; typedef pair ll_i; typedef pair d_i; typedef pair ll_ll; typedef pair d_d; struct edge { int v, w; }; ll MOD = 1000000009; ll _MOD = 1000000009; double EPS = 1e-10; ll f(vector& a, vector& b, ll x) { int N = a.size(); ll mini = LLONG_MAX, maxi = 0; for (int i = 0; i < N; i++) { ll c = a[i] + b[i] * x; mini = min(mini, c); maxi = max(maxi, c); } return maxi - mini; } int main() { int N; cin >> N; vector a(N), b(N); for (int i = 0; i < N; i++) cin >> a[i] >> b[i]; ll x = 1, y = 100000000000LL; while (y - x > 2) { ll z1 = (x * 2 + y) / 3, z2 = (x + y * 2) / 3; ll f1 = f(a, b, z1), f2 = f(a, b, z2); if (f1 > f2) x = z1; else y = z2; } ll_ll ans(LLONG_MAX, 0); ans = min(ans, ll_ll(f(a, b, x), x)); ans = min(ans, ll_ll(f(a, b, x + 1), x + 1)); ans = min(ans, ll_ll(f(a, b, x + 2), x + 2)); cout << ans.second << endl; }