#include <bits/stdc++.h>
const int N = 2e5 + 5;
const double eps = 1e-8;
using namespace std;
int n;
struct node {
  long long a, t, mn, mx;
} p[N];
long long sum[N];
template <typename T>
inline T read() {
  T x = 0, w = 1;
  char c = getchar();
  while (c < '0' || c > '9') {
    if (c == '-') w = -1;
    c = getchar();
  }
  while (c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
  return x * w;
}
bool check(double mid) {
  double mx = 0, tmx = 0;
  for (int i = 1; i <= n; i++) {
    if (p[i].a != p[i - 1].a) mx = tmx;
    if ((1 - mid * p[i].mx / sum[n]) * p[i].a < mx) return 0;
    tmx = max(tmx, (1 - mid * p[i].mn / sum[n]) * p[i].a);
  }
  return 1;
}
bool cmp1(node x, node y) { return x.a * y.t > y.a * x.t; }
bool cmp2(node x, node y) { return x.a < y.a; }
int main() {
  n = read<int>();
  for (int i = 1; i <= n; i++) p[i].a = read<long long>();
  for (int i = 1; i <= n; i++) p[i].t = read<long long>();
  sort(p + 1, p + n + 1, cmp1);
  for (int i = 1; i <= n; i++) sum[i] = sum[i - 1] + p[i].t;
  for (int j = 1, i = 1; i <= n; i = j + 1) {
    j = i;
    while (j < n && p[j].a * p[j + 1].t == p[j + 1].a * p[j].t) j++;
    for (int k = i; k <= j; k++)
      p[k].mn = sum[i - 1] + p[k].t, p[k].mx = sum[j];
  }
  sort(p + 1, p + n + 1, cmp2);
  double l = 0, r = 1, ans = 1, mid;
  while (r - l > eps) {
    mid = (l + r) / 2;
    if (check(mid))
      ans = mid, l = mid;
    else
      r = mid;
  }
  printf("%.11lf\n", ans);
  return 0;
}
