#include "bits/stdc++.h" #include #pragma warning(disable:4996) using namespace std; using ld = long double; template using Table = vector>; vectoras,bs; long long check(const long long tab){ long long amin = as[0] + bs[0] * tab; long long amax = as[0] + bs[0] * tab; for (int i = 1; i < as.size(); ++i){ long long len = as[i] + bs[i] * tab; amin = min(amin, len); amax = max(amax, len); } return amax-amin; } int main() { int N; cin >> N; as.resize(N); bs.resize(N); for (int i = 0; i < N; ++i){ cin >> as[i] >> bs[i]; } long long amin = 0; long long amax = 5e9; { int num = 50; while (num--, num){ long long amid0 = (amin * 2 + amax) / 3; long long amid1 = (amin + amax * 2) / 3; if (check(amid0) < check(amid1)){ amax = amid1; } else{ amin = amid0; } } } long long anslen = check(amin); for (long long i = amin; i < amax; ++i){ anslen = min(check(i), anslen); } long long from; for (long long i = amin; i < amax; ++i){ if (anslen == check(i)){ from = i; break; } } if (from != amin){ cout << from << endl; return 0; }else { long long amin = 0; long long amax = from; while (amin+1!=amax){ long long amid = (amin + amax) / 2; if (check(amid) == anslen){ amax = amid; } else{ amin = amid; } } cout << amax << endl; } return 0; }