#include <bits/stdc++.h>
using namespace std;
const int Maxn = 55;
const int inf = 2147483647;
const double eps = 1e-10;
int read() {
  int x = 0, f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9')
    x = (x << 3) + (x << 1) + (ch ^ 48), ch = getchar();
  return x * f;
}
int n, lim[Maxn];
struct Node {
  int a, b;
} A[Maxn];
bool cmp(Node a, Node b) { return a.a > b.a; }
double v[Maxn], f[Maxn][Maxn][Maxn];
void upd(double &x, double y) { x = min(x, y); }
bool check(double o) {
  for (int i = 1; i <= n; i++) v[i] = (double)A[i].a - (double)A[i].b * o;
  for (int i = 0; i <= n; i++)
    for (int j = 0; j <= n; j++)
      for (int k = 0; k <= n; k++) f[i][j][k] = inf;
  f[0][0][0] = 0;
  for (int i = 0; i < n; i++)
    for (int j = 0; j <= i; j++)
      for (int k = 0; k <= lim[i]; k++)
        if (f[i][j][k] != inf) {
          double t = f[i][j][k];
          if (A[i].a != A[i + 1].a) {
            if (j || k) upd(f[i + 1][j + k - 1][0], t);
            upd(f[i + 1][j + k][1], t + v[i + 1]);
          } else {
            if (j) upd(f[i + 1][j - 1][k], t);
            upd(f[i + 1][j][k + 1], t + v[i + 1]);
          }
        }
  double ans = inf;
  for (int j = 0; j <= n; j++)
    for (int k = 0; k <= lim[n]; k++) upd(ans, f[n][j][k]);
  if (ans <= eps) return true;
  return false;
}
int main() {
  double l = 0, r = 0;
  n = read();
  for (int i = 1; i <= n; i++) A[i].a = read();
  for (int i = 1; i <= n; i++)
    A[i].b = read(), r = max(r, (double)A[i].a / A[i].b);
  sort(A + 1, A + 1 + n, cmp);
  A[0].a = -inf;
  lim[0] = 0;
  for (int i = 1; i <= n; i++) {
    int j = i;
    while (j > 1 && A[j - 1].a == A[i].a) j--;
    lim[i] = i - j + 1;
  }
  int T = 70;
  while (T--) {
    double mid = (l + r) * 0.5;
    if (check(mid))
      r = mid;
    else
      l = mid;
  }
  printf("%lld", (long long)((double)r * 1000 + 0.5));
}
