#include <bits/stdc++.h>
const long long N = 2e5 + 5;
const double eps = 1e-8;
long long n, T, id[N], L[N], R[N];
struct node {
  long long p, t;
} d[N];
inline bool cmp1(node a, node b) { return a.t * b.p < b.t * a.p; }
inline bool cmp2(long long a, long long b) { return d[a].p < d[b].p; }
inline bool check(double c) {
  double a = 0, b = 0;
  long long i;
  for (i = 1; i <= n; i++) {
    if (d[id[i]].p != d[id[i - 1]].p) a = b, b = 0;
    if (d[id[i]].p * (T - c * R[id[i]]) < a) return 0;
    b = std::max(b, d[id[i]].p * (T - c * L[id[i]]));
  }
  return 1;
}
signed main() {
  scanf("%lld", &n);
  long long i, j, k = 0, p = 0, x, y;
  double l = 0, r = 1, mid;
  for (i = 1; i <= n; i++) scanf("%lld", &d[i].p), id[i] = i;
  for (i = 1; i <= n; i++) scanf("%lld", &d[i].t), T += d[i].t;
  std::sort(d + 1, d + n + 1, cmp1), std::sort(id + 1, id + n + 1, cmp2);
  for (y = 1; y <= n; p = k, y++) {
    for (x = y; y < n && !cmp1(d[y], d[y + 1]); y++)
      ;
    for (i = x; i <= y; i++) k += d[i].t;
    for (i = x; i <= y; i++) L[i] = p + d[i].t, R[i] = k;
  }
  for (i = 1; i <= 100; i++) mid = (l + r) / 2, (check(mid) ? l : r) = mid;
  printf("%.15lf\n", mid);
  return 0;
}
