#include #include int main(){ using namespace std; using bigint = boost::multiprecision::cpp_int; unsigned long N; cin >> N; vector> problems(N); for(auto&& [a, _] : problems)cin >> a; for(auto&& [_, b] : problems)cin >> b; reverse(begin(problems), end(problems)); vector> stack; while(!empty(problems)){ auto [a, b]{problems.back()}; problems.pop_back(); while(!empty(stack) && stack.back().first * b >= stack.back().second * a){ a += stack.back().first; b += stack.back().second; stack.pop_back(); } stack.emplace_back(a, b); } long double ans{}; for(const auto& [a, b] : stack)ans += a < b ? static_cast(a) + static_cast(b) : 2 * sqrt(static_cast(a)) * sqrt(static_cast(b)); cout << fixed << setprecision(30) << ans << endl; return 0; }