#include <bits/stdc++.h>
using namespace std;
const int maxN = 55;
const double eps = 1e-6;
const double inf = 1e11;
int n, a[maxN], b[maxN];
inline void cmin(double& x, double y) {
  if (y < x) x = y;
}
int chk(double rate) {
  static pair<int, double> c[maxN];
  static double f[maxN][maxN][maxN];
  int i, j, k;
  for (i = 1; i <= n; ++i) c[i] = make_pair(a[i], a[i] - b[i] * rate);
  sort(c + 1, c + 1 + n);
  for (i = 1; i <= n + 1; ++i) {
    for (j = 0; j <= n; ++j) {
      for (k = 0; k + j <= n; ++k) {
        f[i][j][k] = inf;
      }
    }
  }
  f[n + 1][0][0] = 0;
  for (i = n; i; --i) {
    for (j = 0; j <= n; ++j) {
      for (k = 0; j + k <= n; ++k)
        if (f[i + 1][j][k] < 5e10) {
          if (c[i].first != c[i + 1].first) {
            cmin(f[i][1][j + k], f[i + 1][j][k] + c[i].second);
            if (j + k) cmin(f[i][0][j + k - 1], f[i + 1][j][k]);
          } else {
            cmin(f[i][j + 1][k], f[i + 1][j][k] + c[i].second);
            if (k) cmin(f[i][j][k - 1], f[i + 1][j][k]);
          }
        }
    }
  }
  double res = inf;
  for (i = 0; i <= n; ++i) {
    for (j = 0; j + i <= n; ++j) {
      res = min(res, f[1][i][j]);
    }
  }
  return res < 0;
}
int main() {
  int i, j;
  scanf("%d", &n);
  for (i = 1; i <= n; ++i) scanf("%d", a + i);
  for (i = 1; i <= n; ++i) scanf("%d", b + i);
  double l = 0, r = 1e8;
  for (; l + eps < r;) {
    double mid = (l + r) / 2;
    if (chk(mid))
      r = mid;
    else
      l = mid + eps;
  }
  printf("%.0lf\n", ceil((r - 1e-5) * 1000));
  return 0;
}
