#include <bits/stdc++.h>
using namespace std;
static struct tProblem { long long p, t, sum_t, max_t, min_t; } val[150010];
static int N;
static long long T;
inline bool cmp1(const tProblem x, const tProblem y) {
  return x.p * y.t > y.p * x.t;
}
inline bool cmp2(const tProblem x, const tProblem y) { return x.p < y.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.0, r = 1.0;
  while (r - l > (1e-8)) {
    double mid = (l + r) / 2, mx = -1e10, used_mx = -1e10;
    int flg = 1;
    for (int i = 1; flg && i <= N; i++) {
      if (val[i].p != val[i - 1].p) used_mx = mx;
      if ((1.0 - mid * val[i].max_t / T) * val[i].p < used_mx) flg = 0;
      mx = max(mx, (1.0 - mid * val[i].min_t / T) * val[i].p);
    }
    if (flg)
      l = mid;
    else
      r = mid;
  }
  printf("%.10lf\n", l);
  return 0;
}
