#include #ifndef DUMP #define DUMP(...) (void)0 #endif using namespace std; int main() { cin.tie(nullptr)->sync_with_stdio(false); cout << fixed << setprecision(20); int n; cin >> n; vector p(n), q(n); for (auto&& e : p) cin >> e; for (auto&& e : q) cin >> e; auto chk = [&](double m) { double sum = 0; for (int i = 0; i < n; ++i) { sum += p[i] * (1 - q[i]) / (1 - q[i] * m); } return sum > m; }; double ok = 0, ng = 1; for (int _ = 100; _--;) { double mid = (ok + ng) / 2; (chk(mid) ? ok : ng) = mid; } DUMP(ok); double res = 0; for (int i = 0; i < n; ++i) { int a; cin >> a; res += log((1 - q[i]) / (1 - q[i] * ok)) * a; } cout << res << '\n'; }