#include "bits/stdc++.h" using namespace std; #define int long long #define REP(i, n) for(int i=0; i<(n); i++) #define FOR(i, a, b) for(int i=(a);i<(b);i++) #define MAX 1e15 int N,T; vector A, B; int calc(int x) { int ret = 0; int maxc = 0; int minc = MAX; REP(i,N) { int c = A[i] + B[i] * x; maxc = max(maxc, c); minc = min(minc, c); } return maxc - minc; } signed main() { cin >> N; A.resize(N); B.resize(N); REP(i,N) cin >> A[i] >> B[i]; int high = MAX; int low = 1; while(high - low > 5) { int m1 = low + (high - low) / 3; int m2 = low + (high - low) * 2 / 3; int c1 = calc(m1); int c2 = calc(m2); if (c1 <= c2) { high = m2; } else { low = m1; } } int minc = MAX; int ans = -1; FOR(k,low,high) { int c = calc(k); if (c < minc) { ans = k; minc = c; } } cout << ans << endl; return 0; }