#include <bits/stdc++.h>
using namespace std;
template <typename tp>
inline void read(tp &x) {
  x = 0;
  char c = getchar();
  int f = 0;
  for (; c < '0' || c > '9'; f |= c == '-', c = getchar())
    ;
  for (; c >= '0' && c <= '9'; x = (x << 3) + (x << 1) + c - '0', c = getchar())
    ;
  if (f) x = -x;
}
const long long N = 3e5 + 233;
long long p[N], t[N], id[N], n, T;
inline bool cmp(long long x, long long y) {
  long long l = p[x] * t[y], r = p[y] * t[x];
  return l > r || l == r && p[x] > p[y];
}
inline bool check(double mid) {
  vector<pair<long long, pair<double, double> > > vec;
  long long sum = 0;
  for (register long long l = 1; l <= (n); l++) {
    long long r = l;
    while (r <= n && p[id[l]] * t[id[r]] - p[id[r]] * t[id[l]] == 0) ++r;
    --r;
    long long cur = 0;
    for (long long k = l; k <= r; k++) {
      cur += t[id[k]];
    }
    for (long long k = l; k <= r; k++) {
      vec.emplace_back(
          p[id[k]],
          make_pair(p[id[k]] * (1 - (double)(sum + t[id[k]]) * mid / T),
                    p[id[k]] * (1 - (double)(sum + cur) * mid / T)));
    }
    sum += cur;
    l = r;
  }
  sort(vec.begin(), vec.end());
  double premax = 0;
  for (register long long l = 0; l < (long long)vec.size(); l++) {
    long long r = l;
    while (r < vec.size() && vec[l].first == vec[r].first) ++r;
    --r;
    for (long long k = l; k <= r; k++) {
      if (vec[k].second.second < premax) return false;
    }
    for (long long k = l; k <= r; k++)
      premax = max(premax, vec[k].second.first);
    l = r;
  }
  return true;
}
signed main(void) {
  read(n);
  for (register long long i = 1; i <= (n); i++) read(p[i]);
  for (register long long i = 1; i <= (n); i++) read(t[i]), T += t[i];
  for (register long long i = 1; i <= (n); i++) id[i] = i;
  sort(id + 1, id + n + 1, cmp);
  double l = 0, r = 1;
  for (register long long k = 1; k <= (60); k++) {
    double mid = (l + r) / 2.;
    check(mid) ? l = mid : r = mid;
  }
  printf("%.10f\n", l);
}
