#include #include #include #include #include #include #include #include #include // require sort next_permutation count __gcd reverse etc. #include // require abs exit atof atoi #include // require scanf printf #include #include // require accumulate #include // require fabs #include #include #include #include // require setw #include // require stringstream #include // require memset #include // require tolower, toupper #include // require freopen #include // require srand #define rep(i,n) for(int i=0;i<(n);i++) #define ALL(A) A.begin(), A.end() #define each(i,c) for(auto i=(c).begin();i!=(c).end();++i) #define exist(s,e) ((s).find(e)!=(s).end()) #define clr(a) memset((a),0,sizeof(a)) #define nclr(a) memset((a),-1,sizoef(a)) #define sz(s) (int)((s).size()) #define INRANGE(x,s,e) ((s)<=(x) && (x)<(e)) #define pb push_back #define MP(x,y) make_pair((x),(y)) using namespace std; typedef long long ll; typedef pair P; vector a, b; ll fx(int n, ll x ){ ll maxv = 0LL; ll minv = 1LL<<60; rep (i, n ){ ll v = a[i] + b[i]*x; maxv = max (maxv, v ); minv = min (minv, v ); } // end rep return (maxv - minv ); } int main() { ios_base::sync_with_stdio(0); int N; cin >> N; a.clear(); a.resize(N, 0LL ); b.clear(); b.resize(N, 0LL ); rep (i, N ) cin >> a[i] >> b[i]; ll lo = 1LL; ll hi = 1LL<<30; ll res = 1LL; while (lo <= hi && (hi - lo ) > 3LL ){ ll cl = lo + (hi - lo )/3LL; ll cr = hi - (hi - lo )/3LL; ll suml = fx (N, cl ); ll sumr = fx (N, cr ); if (suml <= sumr ){ hi = cr; }else{ lo = cl; } // end if } // end while ll curr = 1LL<<60; for (ll x = lo; x <= hi; x++ ){ ll sum = fx (N, x ); if (curr > sum ){ res = x; curr = sum; } // end if } // end for cout << res << endl; return 0; }