#include <bits/stdc++.h>
using namespace std;
const int MAXN = 150005;
long long At, T[MAXN];
int P[MAXN], Ord[MAXN], R[MAXN], N;
double S[MAXN];
bool Same(int a, int b) { return P[a] * T[b] == T[a] * P[b]; }
double Val(double c, long long t, int a) { return P[a] * (1 - c * t / At); }
bool cmp1(int a, int b) { return P[a] < P[b]; }
bool cmp(int a, int b) {
  if (!Same(a, b)) return P[a] * T[b] > T[a] * P[b];
  return P[a] < P[b];
}
double Query(int s) {
  double tmp = -(1e10);
  for (; s; s -= s & -s) tmp = max(tmp, S[s]);
  return tmp;
}
void Change(int s, double v) {
  for (; s <= N; s += s & -s) S[s] = max(S[s], v);
}
bool Test(double c) {
  for (int i = 1; i <= N; i++) S[i] = -(1e10);
  for (long long i = 1, t = 0; i <= N;) {
    int k = i;
    long long ft = t;
    for (int j = i; j <= N && Same(Ord[i], Ord[j]); j++) t += T[Ord[j]];
    for (; k <= N && Same(Ord[i], Ord[k]); k++)
      Change(R[Ord[k]], Val(c, ft + T[Ord[k]], Ord[k]));
    for (int j = i; j <= N && Same(Ord[i], Ord[j]); j++)
      if (Query(R[Ord[j]] - 1) > Val(c, t, Ord[j])) return 0;
    i = k;
  }
  return 1;
}
int main() {
  scanf("%d", &N);
  static int Bak[MAXN];
  for (int i = 1; i <= N; i++) scanf("%d", &P[i]), Bak[i] = i;
  for (int i = 1; i <= N; i++) scanf("%d", &T[i]), Ord[i] = i, At += T[i];
  sort(Bak + 1, Bak + N + 1, cmp1);
  R[Bak[1]] = 1;
  for (int i = 2, c = 1; i <= N; i++) {
    if (P[Bak[i]] != P[Bak[c]]) Bak[++c] = Bak[i];
    R[Bak[i]] = c;
  }
  sort(Ord + 1, Ord + N + 1, cmp);
  double l = 0, r = 1, mid;
  for (int i = 1; i <= 70; i++) {
    mid = (l + r) / 2;
    if (Test(mid))
      l = mid;
    else
      r = mid;
  }
  printf("%.10f\n", (l + r) / 2);
  return 0;
}
