#include <bits/stdc++.h>
using namespace std;
const long long N = 300005;
struct node {
  long long p, t;
} s[N];
bool cmp(node x, node y) { return x.t * y.p < y.t * x.p; }
bool cmpp(long long x, long long y) { return s[x].p < s[y].p; }
long long n, sum = 0;
long long lis[N], l[N], r[N];
char chk(double c) {
  double mx = 0.0, mx2 = 0.0;
  long long tmp = -1;
  for (long long i = 1; i <= n; i++) {
    long long now = lis[i];
    if (s[lis[i]].p != s[lis[i - 1]].p) {
      mx = max(mx, mx2);
      mx2 = 0.0;
    }
    if (s[now].p * (sum - c * r[now]) < mx) return 0;
    mx2 = max(mx2, s[now].p * (sum - c * l[now]));
  }
  return 1;
}
int main() {
  long long ls, pre, st, ed;
  scanf("%lld", &n);
  for (long long i = 1; i <= n; i++) scanf("%lld", &s[i].p);
  for (long long i = 1; i <= n; i++) {
    scanf("%lld", &s[i].t);
    sum += s[i].t;
  }
  sort(s + 1, s + 1 + n, cmp);
  ls = 1;
  st = 0;
  ed = 0;
  while (1) {
    pre = ls;
    while (cmp(s[ls], s[ls + 1]) == 0 && ls < n) ls++;
    for (long long i = pre; i <= ls; i++) ed += s[i].t;
    for (long long i = pre; i <= ls; i++) {
      l[i] = st + s[i].t;
      r[i] = ed;
    }
    st = ed;
    ls++;
    if (ls > n) break;
  }
  for (long long i = 1; i <= n; i++) lis[i] = i;
  sort(lis + 1, lis + 1 + n, cmpp);
  double l = 0.0, r = 1.0, mid;
  for (long long ef = 1; ef <= 40; ef++) {
    mid = (l + r) / 2.0;
    if (chk(mid))
      l = mid;
    else
      r = mid;
  }
  printf("%.10lf\n", mid);
  return 0;
}
