#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 5;
struct Node {
  int p, t;
  long long mn, mx;
} a[N];
int n;
long long sum[N], T;
bool cmp1(const Node& a, const Node& b) {
  return 1ll * a.p * b.t > 1ll * b.p * a.t;
}
bool cmp2(const Node& a, const Node& b) { return a.p < b.p; }
bool check(double x) {
  double now = 0, mx = 0;
  for (int i = 1; i <= n; i++) {
    if (a[i].p != a[i - 1].p) mx = now;
    if ((1.0 - x * a[i].mx / T) * a[i].p < mx) return false;
    now = max(now, (1.0 - x * a[i].mn / T) * a[i].p);
  }
  return true;
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i].p);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i].t);
  sort(a + 1, a + n + 1, cmp1);
  for (int i = 1; i <= n; i++) sum[i] = sum[i - 1] + a[i].t;
  T = sum[n];
  for (int i = 1, j; i <= n; i = j + 1) {
    for (j = i; j < n && 1ll * a[i].p * a[j + 1].t == 1ll * a[j + 1].p * a[i].t;
         j++)
      ;
    for (int k = i; k <= j; k++)
      a[k].mn = sum[i - 1] + a[k].t, a[k].mx = sum[j];
  }
  sort(a + 1, a + n + 1, cmp2);
  double l = 0, r = 1;
  while (r - l > (1e-9)) {
    double mid = (l + r) / 2.0;
    if (check(mid))
      l = mid;
    else
      r = mid;
  }
  printf("%.8f", l);
  return 0;
}
