#include <bits/stdc++.h>
inline int gi() {
  int x = 0, f = 1;
  char ch = getchar();
  while (!isdigit(ch)) {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (isdigit(ch)) x = x * 10 + ch - '0', ch = getchar();
  return x * f;
}
struct laji {
  int a, b;
} s[51];
inline bool operator<(const laji& a, const laji& b) {
  if (a.a ^ b.a)
    return a.a > b.a;
  else
    return a.b > b.b;
}
double S[51];
double f[51][51];
inline void chkmn(double& a, double b) {
  if (b < a) a = b;
}
int main() {
  int n = gi();
  for (int i = 1; i <= n; ++i) s[i].a = gi();
  for (int i = 1; i <= n; ++i) s[i].b = gi();
  std::sort(s + 1, s + n + 1);
  double l = 0, r = 1000000000, mid;
  while (r - l > 1e-5) {
    mid = (l + r) * 0.5;
    for (int i = 1; i <= n; ++i) S[i] = s[i].a - mid * s[i].b + S[i - 1];
    for (int i = 1; i <= n; ++i)
      for (int j = 0; j <= i; ++j) f[i][j] = 1e18;
  begin:
    for (int i = 0, p; i < n; i = p)
      for (int j = 0; j <= i; ++j) {
        p = i + 1;
        while (s[p + 1].a == s[i + 1].a) ++p;
        for (int k = 0; k <= p - i && k <= j; ++k)
          chkmn(f[p][j - k + (p - i - k)], f[i][j] + S[p] - S[i + k]);
      }
    double res = 1e18;
    for (int i = 0; i <= n; ++i) chkmn(res, f[n][i]);
    if (res > 0)
      l = mid;
    else
      r = mid;
  }
  printf("%lld\n", (long long)round((l + r) * 500));
  return 0;
}
