#include <bits/stdc++.h>
using namespace std;
inline void read(long long &x) {
  long long w = 1;
  x = 0;
  char c = getchar();
  while (c < '0' || c > '9') {
    if (c == '-') w = -1;
    c = getchar();
  }
  while (c >= '0' && c <= '9') {
    x = x * 10 + c - '0';
    c = getchar();
  }
  x *= w;
}
struct date {
  long long val, t, id;
} eve[200010];
bool cmp1(date a, date b) { return a.val < b.val; }
bool cmp(date a, date b) {
  if (a.val * b.t == b.val * a.t) return a.val < b.val;
  return a.val * b.t > b.val * a.t;
}
map<long long, long long> mmp;
double maxx[200010], minn[200010];
signed main() {
  long long n, cnt = 0, t = 0;
  read(n);
  for (long long i = 1; i <= n; i++) read(eve[i].val);
  for (long long i = 1; i <= n; i++) read(eve[i].t), t += eve[i].t;
  sort(eve + 1, eve + n + 1, cmp1);
  for (long long i = 1; i <= n; i++) {
    if (!mmp[eve[i].val]) mmp[eve[i].val] = ++cnt;
    eve[i].id = mmp[eve[i].val];
  }
  sort(eve + 1, eve + n + 1, cmp);
  eve[n + 1].val = 999;
  double l = 0, r = 1;
  while (l < r) {
    double mid = (l + r) / 2;
    long long tn = 0, tl = 0, fi = 1;
    for (long long i = 1; i <= cnt; i++) {
      maxx[i] = -9999999;
      minn[i] = 99999999;
    }
    for (long long i = 1; i <= n; i++) {
      tl += eve[i].t;
      if (eve[i].t * eve[i + 1].val != eve[i + 1].t * eve[i].val) {
        for (long long j = fi; j <= i; j++) {
          maxx[eve[j].id] =
              max(maxx[eve[j].id],
                  eve[j].val * (1 - mid * (double)(tn + eve[j].t) / t));
          minn[eve[j].id] =
              min(minn[eve[j].id], eve[j].val * (1 - mid * (double)tl / t));
        }
        tn = tl;
        fi = i + 1;
      }
    }
    bool ok = 0;
    double ma = -9999999;
    for (long long i = 1; i <= cnt; i++) {
      if (ma > minn[i]) {
        ok = 1;
        break;
      }
      ma = max(ma, maxx[i]);
    }
    if (ok)
      r = mid - 0.0000001;
    else
      l = mid + 0.0000001;
  }
  cout << fixed << setprecision(11) << l;
}
