#include <bits/stdc++.h>
using namespace std;
const int N = 55;
const double eps = 1e-6;
inline long long rd() {
  int x = 0, w = 1;
  char ch = 0;
  while (ch < '0' || ch > '9') {
    if (ch == '-') w = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = (x << 3) + (x << 1) + (ch ^ 48);
    ch = getchar();
  }
  return x * w;
}
struct node {
  double a, b;
  bool operator<(const node &bb) const {
    return a != bb.a ? a > bb.a : b > bb.b;
  }
} a[N];
int n;
double c[N], f[N][N];
inline bool check(double mid) {
  for (int i = 1; i <= n; ++i) c[i] = c[i - 1] + (a[i].a * 1000 - mid * a[i].b);
  int ii = 0;
  for (int i = 1, j = 1; i <= n; ++j, i = j) {
    ++ii;
    for (int k = 0; k <= n; ++k) f[ii][k] = 1e18;
    while (fabs(a[j + 1].a - a[j].a) < eps) ++j;
    for (int k = 0; k <= j - i + 1; ++k)
      for (int l = j - i + 1 - k; l < i; ++l)
        f[ii][l - (j - i + 1 - k) + k] =
            min(f[ii][l - (j - i + 1 - k) + k],
                f[ii - 1][l] + c[i + k - 1] - c[i - 1]);
  }
  double ma = f[0][1];
  for (int l = 0; l <= n; ++l) ma = min(ma, f[ii][l]);
  return ma < -1e-10;
}
int main() {
  n = rd();
  for (int i = 1; i <= n; ++i) a[i].a = rd();
  for (int i = 1; i <= n; ++i) a[i].b = rd();
  sort(a + 1, a + n + 1);
  double l = 0, r = a[1].a * 1000, z = r;
  for (int k = 0; k <= n; ++k) f[0][k] = 1e18;
  f[0][0] = 0;
  while (r - l > eps) {
    double mid = (l + r) / 2;
    if (check(mid))
      z = mid, r = mid - eps;
    else
      l = mid + eps;
  }
  printf("%.0lf\n", z);
  return 0;
}
