#include <bits/stdc++.h>
using namespace std;
const double eps = 1e-10;
struct str {
  long long a, t;
  int id;
} p[400007];
bool operator<(str i, str j) { return i.a * j.t > i.t * j.a; }
bool operator==(str i, str j) { return i.a * j.t == i.t * j.a; }
bool cmp(str i, str j) { return i.a < j.a; }
long long T, ls[400007], rs[400007];
int n;
bool check(double c) {
  double maxb = -1;
  int l = 1, r = 0;
  while (l <= n) {
    r = l;
    while (r < n && p[r].a == p[r + 1].a) r++;
    for (int i = l; i <= r; i++) {
      int id = p[i].id;
      long long a = p[i].a;
      long long Ti = rs[id];
      if (maxb > a * (T - c * Ti)) return false;
    }
    for (int i = l; i <= r; i++) {
      int id = p[i].id;
      long long a = p[i].a, t = p[i].t;
      long long Ti = ls[id] + t;
      maxb = max(maxb, a * (T - c * Ti));
    }
    l = r + 1;
  }
  return true;
}
double bin() {
  double l = 0, r = 1;
  while (r - l > eps) {
    double mid = (l + r) / 2;
    if (check(mid))
      l = mid;
    else
      r = mid;
  }
  return r;
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%lld", &p[i].a), p[i].id = i;
  for (int i = 1; i <= n; i++) scanf("%lld", &p[i].t), T += p[i].t;
  sort(p + 1, p + n + 1);
  int l = 1, r = 0;
  long long suml = 0, sumr = 0;
  while (l <= n) {
    suml = sumr;
    r = l;
    sumr += p[r].t;
    while (r < n && p[r] == p[r + 1]) r++, sumr += p[r].t;
    for (int i = l; i <= r; i++) ls[p[i].id] = suml, rs[p[i].id] = sumr;
    l = r + 1;
  }
  sort(p + 1, p + n + 1, cmp);
  printf("%.10lf\n", bin());
  return 0;
}
