#include <bits/stdc++.h>
using namespace std;
const int maxn = 55;
int n, a[maxn], b[maxn];
double f[maxn][maxn][maxn];
struct S {
  int a, b;
  bool operator<(const S& A) const { return a < A.a; }
} s[maxn];
void Min(double& x, double y) {
  if (x > y) x = y;
}
bool test(double v) {
  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] = 1e12;
      }
    }
  }
  f[0][0][0] = 0;
  for (int i = 1; i <= n; i++) {
    if (s[i].a == s[i - 1].a) {
      for (int j = 0; j <= n; j++) {
        for (int k = 0; k <= n; k++) {
          Min(f[i][j + 1][k], f[i - 1][j][k]);
          Min(f[i][j][k], f[i - 1][j][k] + s[i].a - v * s[i].b);
          if (k) Min(f[i][j][k - 1], f[i - 1][j][k] + s[i].a - v * s[i].b);
        }
      }
    } else {
      for (int j = 0; j <= n; j++) {
        for (int k = 0; k <= n; k++) {
          Min(f[i][1][j + k], f[i - 1][j][k]);
          Min(f[i][0][j + k], f[i - 1][j][k] + s[i].a - v * s[i].b);
          if (j + k)
            Min(f[i][0][j + k - 1], f[i - 1][j][k] + s[i].a - v * s[i].b);
        }
      }
    }
  }
  return f[n][0][0] <= 0;
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", &s[i].a);
  for (int i = 1; i <= n; i++) scanf("%d", &s[i].b);
  sort(s + 1, s + 1 + n);
  test(9);
  double l = 0, r = 1e9;
  while (r - l > 1e-6) {
    double mid = (l + r) / 2;
    if (test(mid))
      r = mid;
    else
      l = mid;
  }
  printf("%lld\n", (long long)ceil(l * 1000));
  return 0;
}
