#include <bits/stdc++.h>
using namespace std;
inline int read() {
  int x = 0, f = 1;
  char ch = getchar();
  while (!isdigit(ch)) {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (isdigit(ch)) {
    x = x * 10 + ch - 48;
    ch = getchar();
  }
  return x * f;
}
int n, t[200050], b[200050];
long long T;
struct node {
  long long p, t, lt, rt, sum, fp;
} p[200050];
inline bool comp1(node a, node b) { return a.p * b.t > b.p * a.t; }
inline bool comp2(node a, node b) { return a.p < b.p; }
inline bool check(double x) {
  double max1 = 0, max2 = 0;
  for (int i = 1; i <= n; i++) {
    if (p[i].p != p[i - 1].p) max1 = max2;
    if ((1 - x * p[i].rt / T) * p[i].p < max1) return false;
    max2 = max(max2, (1 - x * p[i].lt / T) * p[i].p);
  }
  return true;
}
int main() {
  n = read();
  for (int i = 1; i <= n; i++) p[i].p = b[i] = read();
  for (int i = 1; i <= n; i++) p[i].t = read();
  for (int i = 1; i <= n; i++) T += p[i].t;
  sort(b + 1, b + n + 1);
  int cnt = unique(b + 1, b + n + 1) - b - 1;
  for (int i = 1; i <= cnt; i++)
    p[i].fp = lower_bound(b + 1, b + n + 1, p[i].p) - b;
  sort(p + 1, p + n + 1, comp1);
  for (int i = 1; i <= n; i++) p[i].sum = p[i - 1].sum + p[i].t;
  for (int i = 1, j = 0; i <= n; i = j + 1) {
    j = i;
    while (j < n && p[j + 1].p * p[i].t == p[j + 1].t * p[i].p) j++;
    for (int k = i; k <= j; k++) {
      p[k].lt = p[i - 1].sum + p[k].t;
      p[k].rt = p[j].sum;
    }
  }
  sort(p + 1, p + n + 1, comp2);
  double l = 0.0, r = 1.0;
  while (r - l > 1e-6) {
    double mid = (l + r) / 2.0;
    if (check(mid))
      l = mid;
    else
      r = mid;
  }
  printf("%.8lf\n", l);
  return 0;
}
