#include <bits/stdc++.h>
using namespace std;
typedef struct {
  int a, t, idx, blo;
} Node;
Node a[1000010];
long long Sum[1000010], T;
const double eps = 1e-9;
inline int read() {
  int x = 0;
  char ch = getchar();
  while (!isdigit(ch)) ch = getchar();
  while (isdigit(ch)) x = x * 10 + ch - '0', ch = getchar();
  return x;
}
inline int cmp(Node a, Node b) { return 1LL * a.a * b.t > 1LL * b.a * a.t; }
inline int cmp2(Node a, Node b) { return a.a < b.a; }
inline int check(long double c, int n) {
  long double Max = 0;
  for (int l = 1, r = 0; l <= n; l = r + 1) {
    while (r < n && a[r + 1].a == a[l].a) ++r;
    for (int i = l; i <= r; i++) {
      long double Min = a[i].a * (1 - c * Sum[a[i].blo + 1] / T);
      if (Min < Max) return false;
    }
    for (int i = l; i <= r; i++)
      Max = max(Max, a[i].a * (1 - c * (Sum[a[i].blo] + a[i].t) / T));
  }
  return true;
}
int main() {
  int n = read();
  for (int i = 1; i <= n; i++) a[i].idx = i;
  for (int i = 1; i <= n; i++) a[i].a = read();
  for (int i = 1; i <= n; i++) a[i].t = read();
  for (int i = 1; i <= n; i++) T += a[i].t;
  sort(a + 1, a + n + 1, cmp);
  long long sum = 0, Blo = 0;
  for (int i = 1; i <= n; sum += a[i].t, a[i].blo = Blo, i++) {
    if (i == 1 || 1LL * a[i].a * a[i - 1].t != 1LL * a[i - 1].a * a[i].t)
      Sum[++Blo] = sum;
  }
  Sum[++Blo] = sum;
  sort(a + 1, a + n + 1, cmp2);
  double l = 0, r = 1;
  while (r - l > eps) {
    double mid = (l + r) / 2;
    check(mid, n) ? l = mid : r = mid;
  }
  printf("%0.10lf\n", l);
  return 0;
}
