#include <bits/stdc++.h>
using namespace std;
template <typename T>
inline T read(register T& t) {
  register T f = 1;
  register char ch = getchar();
  t = 0;
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -f;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') t = t * 10 + ch - '0', ch = getchar();
  t *= f;
  return t;
}
template <typename T, typename... Args>
inline void read(T& t, Args&... args) {
  read(t);
  read(args...);
}
const long long p = 998244353;
inline long long power(register long long x, register long long k = p - 2) {
  register long long re = 1;
  for (; k; k >>= 1, x = x * x % p)
    if (k & 1) re = re * x % p;
  return re;
}
int n;
struct qaq {
  long long p, t;
} qwq[150005];
bool operator<(qaq a, qaq b) { return a.p * b.t > b.p * a.t; }
map<qaq, vector<int> > mp;
long long fst[150005], lst[150005];
long long sum = 0;
double calc(int id, long long T, double c) {
  return (1.0 - c * T / sum) * qwq[id].p;
}
bool ck(double c) {
  double ls = 1e18;
  double tp = calc(1, lst[1], c);
  for (int i = 2; i <= n; i++) {
    if (qwq[i].p != qwq[i - 1].p) ls = min(ls, tp);
    if (calc(i, fst[i], c) > ls) return 0;
    tp = min(tp, calc(i, lst[i], c));
  }
  return 1;
}
int main() {
  read(n);
  for (int i = 1; i <= n; i++) read(qwq[i].p);
  for (int i = 1; i <= n; i++) read(qwq[i].t);
  sort(qwq + 1, qwq + n + 1, [](qaq a, qaq b) { return a.p > b.p; });
  for (int i = 1; i <= n; i++) mp[qwq[i]].push_back(i);
  for (auto i : mp) {
    for (int j : i.second) fst[j] = sum + qwq[j].t;
    for (int j : i.second) sum += qwq[j].t;
    for (int j : i.second) lst[j] = sum;
    assert(sum >= 0);
  }
  double l = 0, r = 1;
  for (int i = 1; i <= 100; i++) {
    double mid = (l + r) / 2;
    if (ck(mid))
      l = mid;
    else
      r = mid;
  }
  printf("%.9lf\n", l);
  return 0;
}
