#include <bits/stdc++.h>
using namespace std;
int n;
struct task {
  long long a, b;
} s[55];
long long f[55][55][55];
bool cmp(task A, task B) { return A.a > B.a; }
bool check(long long p) {
  memset(f, 0x3f, sizeof(f));
  f[1][0][1] = s[1].a - p * s[1].b;
  for (int i = 1; i <= n; i++)
    for (int j = 0; j <= i; j++)
      for (int k = 0; k <= i; k++) {
        if (s[i].a == s[i - 1].a) {
          if (k >= 1)
            f[i][j][k] =
                min(f[i][j][k], f[i - 1][j][k - 1] + s[i].a - p * s[i].b);
          if (j + 1 <= i - 1) f[i][j][k] = min(f[i][j][k], f[i - 1][j + 1][k]);
        }
        if (s[i].a != s[i + 1].a) {
          f[i + 1][j + k][1] =
              min(f[i + 1][j + k][1], f[i][j][k] + s[i + 1].a - p * s[i + 1].b);
          f[i + 1][j + k - 1][0] = min(f[i + 1][j + k - 1][0], f[i][j][k]);
        }
      }
  for (int j = 0; j <= n; j++)
    for (int k = 0; k <= n; k++)
      if (f[n][j][k] <= 0) return true;
  return false;
}
long long erfen() {
  long long l = 0, r = 1e11, m;
  while (r - l > 1) {
    m = (l + r) >> 1;
    if (check(m))
      r = m;
    else
      l = m;
  }
  return r;
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%lld", &s[i].a);
    s[i].a *= 1000;
  }
  for (int i = 1; i <= n; i++) scanf("%lld", &s[i].b);
  sort(s + 1, s + 1 + n, cmp);
  printf("%lld", erfen());
  return 0;
}
