// C++, WA #include #include #include #include #include using namespace std; using Float = long double; auto make_convex_slope(const vector &A, const vector &B) { long long x = 0, y = 0; vector> ret{{0, 0}}; vector> seq; for (int i = 0; i < (int)A.size(); ++i) seq.emplace_back(Float(B[i]) / A[i], A[i], B[i]); sort(seq.begin(), seq.end()); for (const auto &[_, a, b] : seq) { x += a; y += b; ret.emplace_back(x, y); } return ret; } bool float_fake_solve(const vector &A, const vector &B, const vector &C, const vector &D) { const int n = A.size(); vector> AB, CD; for (int i = 0; i < n; ++i) { AB.emplace_back(Float(B.at(i)) / A.at(i), i); CD.emplace_back(Float(D.at(i)) / C.at(i), i); } sort(AB.begin(), AB.end()); sort(CD.begin(), CD.end()); auto lb_xys = make_convex_slope(A, B); auto ub_xys = make_convex_slope(C, D); for (int i = 0; i < (int)lb_xys.size() - 1; ++i) { auto [x0, y0] = lb_xys.at(i); auto [x1, y1] = lb_xys.at(i + 1); for (const auto &[x, y] : ub_xys) { if ((__int128)(x1 - x0) * (y - y0) - (__int128)(y1 - y0) * (x - x0) < 0) return false; } } vector ab_indices, cd_indices; for (const auto &[_, i] : AB) ab_indices.push_back(i); for (const auto &[_, i] : CD) cd_indices.push_back(i); if (ab_indices == cd_indices) return true; Float vx = 0, vy = 0; for (int i = 0; i < n - 1; ++i) { auto [px, py] = ub_xys.at(i + 1); if (px <= vx) return true; Float a1 = (py - vy) / (px - vx); Float b1 = vy - a1 * vx; auto [ax, ay] = lb_xys[i + 1]; auto [bx, by] = lb_xys[i + 2]; Float a2 = Float(by - ay) / (bx - ax); Float b2 = ay - a2 * ax; if (a1 >= a2) return true; vx = (b2 - b1) / (a1 - a2); vy = a1 * vx + b1; if (vx >= bx) return true; } return false; } int main() { int n; cin >> n; vector A(n), B(n), C(n), D(n); for (auto &a : A) cin >> a; for (auto &b : B) cin >> b; for (auto &c : C) cin >> c; for (auto &d : D) cin >> d; cout << (float_fake_solve(A, B, C, D) ? "Yes" : "No") << '\n'; }