#include <bits/stdc++.h>
using namespace std;
inline int read() {
  register int x = 0, f = 1;
  register char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') x = x * 10 + (ch ^ 48), ch = getchar();
  return x * f;
}
const int N = 2e5 + 5;
struct each {
  int t, p;
  bool operator<(const each k) const { return p < k.p; }
} a[N];
int n, id[N];
long long t, lt[N], rt[N];
bool com(int x, int y) { return 1LL * a[x].t * a[y].p < 1LL * a[y].t * a[x].p; }
bool check(double x) {
  double mx = 0, las = 0;
  for (int i = 1; i <= n; i++) {
    double k = a[i].p * (1 - x * rt[i] / t);
    if (k < las) return false;
    mx = max(mx, a[i].p * (1 - x * lt[i] / t));
    if (a[i].p != a[i + 1].p) las = mx;
  }
  return true;
}
int main() {
  n = read();
  for (int i = 1; i <= n; i++) a[i].p = read();
  for (int i = 1; i <= n; i++) a[i].t = read(), t += a[i].t;
  sort(a + 1, a + n + 1);
  for (int i = 1; i <= n; i++) id[i] = i;
  sort(id + 1, id + n + 1, com);
  long long ti = 0;
  for (int i = 1; i <= n;) {
    int j = i;
    while (j <= n &&
           1LL * a[id[i]].p * a[id[j]].t == 1LL * a[id[j]].p * a[id[i]].t)
      ++j;
    for (int k = i; k < j; k++) lt[id[k]] = ti + a[id[k]].t;
    for (int k = i; k < j; k++) ti += a[id[k]].t;
    for (int k = i; k < j; k++) rt[id[k]] = ti;
    i = j;
  }
  double l = 0, r = 1;
  while (l + 0.0000001 < r) {
    double mid = (l + r) / 2;
    if (check(mid))
      l = mid;
    else
      r = mid;
  }
  printf("%.6lf\n", l);
  return 0;
}
