#include <bits/stdc++.h>
using namespace std;
int read();
int n;
long long T;
struct P {
  long long p, t, tmin, tmax, sum;
} p[200005];
bool cmppdivt(P a, P b) { return a.p * b.t > b.p * a.t; }
bool cmpp(P a, P b) { return a.p < b.p; }
bool check(double x) {
  double mx = 0, tmx = 0;
  for (int i = 1; i <= n; ++i) {
    if (p[i].p != p[i - 1].p) mx = tmx;
    if ((1 - x * p[i].tmax / T) * p[i].p < mx) return 0;
    tmx = max(tmx, (1 - x * p[i].tmin / T) * p[i].p);
  }
  return 1;
}
int main() {
  n = read();
  for (int i = 1; i <= n; ++i) p[i].p = read();
  for (int i = 1; i <= n; ++i) T += (p[i].t = read());
  sort(p + 1, p + 1 + n, cmppdivt);
  for (int i = 1; i <= n; ++i) p[i].sum = p[i - 1].sum + p[i].t;
  for (int i = 1, j; i <= n; i = j + 1) {
    j = i;
    while (j < n && p[j + 1].p * p[i].t == p[i].p * p[j + 1].t) ++j;
    for (int k = i; k <= j; ++k)
      p[k].tmin = p[i - 1].sum + p[k].t, p[k].tmax = p[j].sum;
  }
  sort(p + 1, p + 1 + n, cmpp);
  double l = 0, r = 1, mid;
  while (r - l > 1e-6) check(mid = (l + r) / 2) ? l = mid : r = mid;
  printf("%.8lf", l);
  return 0;
}
const int _SIZE = 1 << 22;
char ibuf[_SIZE], *iS = ibuf, *iT = ibuf;
int read() {
  int x = 0, f = 1;
  char c = (iS == iT ? iT = ((iS = ibuf) + fread(ibuf, 1, _SIZE, stdin)),
            (iS == iT ? EOF : *iS++) : *iS++);
  while (!isdigit(c))
    f = (c == '-') ? -1 : f,
    c = (iS == iT ? iT = ((iS = ibuf) + fread(ibuf, 1, _SIZE, stdin)),
         (iS == iT ? EOF : *iS++) : *iS++);
  while (isdigit(c))
    x = x * 10 + c - '0',
    c = (iS == iT ? iT = ((iS = ibuf) + fread(ibuf, 1, _SIZE, stdin)),
         (iS == iT ? EOF : *iS++) : *iS++);
  return x * f;
}
