#include <bits/stdc++.h>
using namespace std;
template <typename T>
bool vmax(T& a, T b) {
  return (a < b) ? (a = b, true) : false;
}
const int N = 2e5 + 5;
typedef class Problem {
 public:
  int a, t;
  bool operator<(Problem b) const { return 1ll * t * b.a < 1ll * a * b.t; }
  bool operator==(Problem b) const { return 1ll * t * b.a == 1ll * a * b.t; }
} Problem;
int n;
long long Tall;
Problem a[N];
int ord[N];
int bel[N];
vector<long long> sum;
vector<pair<int, int>> segs;
double calc_miv(int p, double c) {
  return a[p].a * (1.0 - c * sum[bel[p] + 1] / Tall);
}
double calc_mxv(int p, double c) {
  return a[p].a * (1.0 - c * (sum[bel[p]] + a[p].t) / Tall);
}
bool check(double c) {
  double miv = 1e100;
  for (int l = 1, r = 1; l <= n; l = r) {
    while (r <= n && a[ord[r]].a == a[ord[l]].a) {
      int p = ord[r];
      double v = calc_mxv(p, c);
      if (v > miv) {
        return false;
      }
      r++;
    }
    for (int i = l; i < r; i++) {
      int p = ord[i];
      double v = calc_miv(p, c);
      miv = min(miv, v);
    }
  }
  return true;
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i].a);
  }
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i].t);
    Tall += a[i].t;
  }
  sort(a + 1, a + n + 1);
  long long cursum = 0;
  for (int l = 1, r = 1; l <= n; l = r) {
    sum.push_back(cursum);
    while (r <= n && a[r] == a[l]) {
      bel[r] = segs.size();
      cursum += a[r].t;
      r++;
    }
    segs.emplace_back(l, r - 1);
  }
  sum.push_back(cursum);
  for (int i = 1; i <= n; i++) {
    ord[i] = i;
  }
  sort(ord + 1, ord + n + 1, [&](int x, int y) { return a[x].a > a[y].a; });
  double l = 0, r = 1;
  for (int _ = 0; l + 1e-9 < r && _ < 64; _++) {
    double mid = (l + r) / 2;
    if (check(mid)) {
      l = mid;
    } else {
      r = mid;
    }
  }
  printf("%.9lf\n", l);
  return 0;
}
