#include <bits/stdc++.h>
using i64 = long long;
const int N = 200000 + 7;
int n;
struct str {
  int a, t;
} v[N];
i64 sum[N], T;
int stt[N], ext[N];
int e[N];
int judge(double C) {
  static double lft[N], rht[N], suf[N];
  auto fb = [&](int x, i64 t) -> double { return v[x].a * (1 - C * t / T); };
  for (int i = 1; i <= n; ++i)
    lft[i] = fb(i, sum[stt[i] - 1] + v[i].t), rht[i] = fb(i, sum[ext[i]]);
  double largest = 0;
  for (int i = 1, j; i <= n; i = j) {
    for (j = i; j <= n && v[e[i]].a == v[e[j]].a; ++j)
      if (rht[e[j]] < largest) return 0;
    for (j = i; j <= n && v[e[i]].a == v[e[j]].a; ++j)
      largest = std::max(largest, lft[e[j]]);
  }
  for (int i = n; i; --i) {
    if (i < ext[i] && v[i].a == v[i + 1].a) continue;
    suf[i] = i < ext[i] ? std::max(lft[i], suf[i + 1]) : 0;
    if (i < ext[i] && suf[i + 1] > rht[i]) return 0;
  }
  return 1;
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) scanf("%d", &v[i].a);
  for (int i = 1; i <= n; ++i) scanf("%d", &v[i].t);
  std::sort(v + 1, v + n + 1, [&](str a, str b) {
    if (1ll * a.a * b.t != 1ll * b.a * a.t)
      return 1ll * a.a * b.t > 1ll * b.a * a.t;
    return a.a > b.a;
  });
  for (int i = 1, j; i <= n; i = j) {
    for (j = i; j <= n && 1ll * v[i].a * v[j].t == 1ll * v[j].a * v[i].t; ++j)
      ;
    stt[i] = i, ext[i] = j - 1;
    for (j = i; j <= ext[i]; ++j) stt[j] = i, ext[j] = ext[i];
  }
  for (int i = 1; i <= n; ++i) sum[i] = sum[i - 1] + v[i].t;
  T = sum[n];
  for (int i = 1; i <= n; ++i) e[i] = i;
  std::sort(e + 1, e + n + 1, [](int a, int b) {
    return v[a].a == v[b].a ? a > b : v[a].a < v[b].a;
  });
  double l = 0.000000001, r = 1, m;
  for (int t = 0; t < 100; ++t) judge(m = (l + r) / 2) ? (l = m) : (r = m);
  printf("%0.11lf\n", l);
  return 0;
}
