#include <bits/stdc++.h>
using namespace std;
const int MAXN = 52, INF = 2147483647;
const double eps = 1e-5;
double l = 0.0, r = 1e8, mid;
int n;
double f[MAXN][MAXN][MAXN];
struct rec {
  double a, b;
} t[MAXN];
bool cmp(rec x, rec y) { return x.a > y.a; }
void dfs(int i) {
  if (i == 0) return;
  dfs(i - 1);
  if (t[i].a < t[i - 1].a) {
    for (int j = 0; j <= n; ++j)
      for (int k = 0; k <= n; ++k) {
        if (j - k + 1 >= 0)
          f[i][j][0] = min(f[i][j][0], f[i - 1][j - k + 1][k]);
        if (j - k >= 0)
          f[i][j][1] =
              min(f[i][j][1], f[i - 1][j - k][k] + t[i].a - mid * t[i].b);
      }
  } else if (t[i].a == t[i - 1].a) {
    for (int j = 0; j <= n; ++j)
      for (int k = 0; k <= n; ++k) {
        if (k >= 1)
          f[i][j][k] =
              min(f[i - 1][j][k - 1] + t[i].a - mid * t[i].b, f[i][j][k]);
        f[i][j][k] = min(f[i][j][k], f[i - 1][j + 1][k]);
      }
  }
}
bool judge(double x) {
  dfs(n);
  for (int i = 0; i <= n; ++i)
    for (int j = 0; j <= n; ++j)
      if (f[n][i][j] <= eps) return 1;
  return 0;
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) scanf("%lf", &t[i].a);
  for (int i = 1; i <= n; ++i) scanf("%lf", &t[i].b);
  sort(t + 1, t + 1 + n, cmp);
  t[0].a = INF * 1.0;
  mid = 9.0;
  while (r - l > eps) {
    mid = (l + r) / 2;
    for (int i = 0; i <= n + 1; ++i)
      for (int j = 0; j <= n + 1; ++j)
        for (int k = 0; k <= n + 1; ++k) f[i][j][k] = INF * 1.0;
    f[0][0][0] = 0.0;
    if (judge(mid))
      r = mid;
    else
      l = mid;
  }
  printf("%lld", (long long)ceil(l * 1000));
  return 0;
}
