#include <bits/stdc++.h>
using namespace std;
class problem {
 public:
  long long p, t, sum_t, max_t, min_t;
} val[150010];
int n;
long long T;
inline int cmp1(const problem &a, const problem &b) {
  return a.p * b.t > b.p * a.t;
}
inline int cmp2(const problem &a, const problem &b) { return a.p < b.p; }
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%lld", &val[i].p);
  for (int i = 1; i <= n; i++) scanf("%lld", &val[i].t), T += val[i].t;
  sort(val + 1, val + n + 1, cmp1);
  for (int i = 1; i <= n; i++) val[i].sum_t = val[i - 1].sum_t + val[i].t;
  for (int i = 1, j; i <= n; i = j) {
    for (j = i; j <= n && val[i].p * val[j].t == val[j].p * val[i].t; j++)
      ;
    for (int k = i; k < j; k++) {
      val[k].min_t = val[i - 1].sum_t + val[k].t;
      val[k].max_t = val[j - 1].sum_t;
    }
  }
  sort(val + 1, val + n + 1, cmp2);
  double l = 0, r = 1;
  while (r - l > 1e-8) {
    double mid = (l + r) / 2;
    double mx = -1e18, used_mx = -1e18;
    bool flag = 1;
    for (int i = 1; flag && i <= n; i++) {
      if (val[i].p != val[i - 1].p) used_mx = mx;
      if ((1 - mid * val[i].max_t / T) * val[i].p < used_mx) flag = 0;
      mx = max(mx, (1.0 - mid * val[i].min_t / T) * val[i].p);
    }
    if (flag)
      l = mid;
    else
      r = mid;
  }
  printf("%.10lf\n", l);
  return 0;
}
