#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 = INT_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]; int x = 1, y = 1000000000; while (y - x > 2) { int 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_i ans(LLONG_MAX, 0); ans = min(ans, ll_i(f(a, b, x), x)); ans = min(ans, ll_i(f(a, b, x + 1), x + 1)); ans = min(ans, ll_i(f(a, b, x + 2), x + 2)); cout << ans.second << endl; }