#include <bits/stdc++.h>
using namespace std;
inline char gc() {
  return getchar();
  static char buf[100000], *l = buf, *r = buf;
  return l == r && (r = (l = buf) + fread(buf, 1, 100000, stdin), l == r)
             ? EOF
             : *l++;
}
template <class T>
void rd(T &x) {
  x = 0;
  int f = 1, ch = gc();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = gc();
  }
  while (ch >= '0' && ch <= '9') {
    x = x * 10 - '0' + ch;
    ch = gc();
  }
  x *= f;
}
template <class T>
inline bool Cmax(T &x, T y) {
  return x < y ? x = y, 1 : 0;
}
const double eps = 1e-8;
const int maxn = 150000 + 50;
int n, T;
int ord[maxn];
int m, bel[maxn];
long long R[maxn];
double mn[maxn], mx[maxn];
struct node {
  int p, t;
  inline bool operator<(const node &other) const {
    return (long long)p * other.t > (long long)other.p * t;
  }
} a[maxn];
inline bool cmp(const int &x, const int &y) { return a[x].p < a[y].p; }
bool check(double c) {
  double t = 0;
  for (int i = 1; i <= n; ++i) {
    int x = ord[i], y = bel[x];
    mn[i] = a[x].p * (1 - c * R[y] / R[m]);
    mx[i] = a[x].p * (1 - c * (R[y - 1] + a[x].t) / R[m]);
  }
  for (int i = 1, j; i <= n; i = j) {
    j = i;
    while (j <= n && a[ord[j]].p == a[ord[i]].p) ++j;
    for (int k = i; k < j; ++k)
      if (t > mn[k]) return 0;
    for (int k = i; k < j; ++k) Cmax(t, mx[k]);
  }
  return 1;
}
int main() {
  rd(n);
  for (int i = 1; i <= n; ++i) rd(a[i].p);
  for (int i = 1; i <= n; ++i) rd(a[i].t);
  sort(a + 1, a + n + 1);
  for (int i = 1; i <= n; ++i) ord[i] = i;
  sort(ord + 1, ord + n + 1, cmp);
  for (int i = 1, j; i <= n; i = j) {
    j = i;
    while (j <= n && !(a[i] < a[j])) ++j;
    ++m, R[m] = R[m - 1];
    for (int k = i; k < j; ++k) bel[k] = m, R[m] += a[k].t;
  }
  double l = 0, r = 1;
  while (r - l > eps) {
    double mid = (l + r) / 2;
    if (check(mid))
      l = mid;
    else
      r = mid;
  }
  printf("%.10lf\n", l);
  return 0;
}
