#include <bits/stdc++.h>
using namespace std;
const int N = 55;
inline long long rd() {
  long long x = 0, w = 1;
  char ch = 0;
  while (ch < '0' || ch > '9') {
    if (ch == '-') w = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = (x << 3) + (x << 1) + (ch ^ 48);
    ch = getchar();
  }
  return x * w;
}
struct node {
  long long a, b;
  bool operator<(const node &bb) const {
    return a != bb.a ? a > bb.a : b > bb.b;
  }
} a[N];
int n;
long long c[N], f[N][N];
inline bool check(long long mid) {
  memset(f, 0x3f, sizeof(f));
  f[0][0] = 0;
  for (int i = 1; i <= n; ++i) c[i] = c[i - 1] + a[i].a - mid * a[i].b;
  int ii = 0;
  for (int i = 1, j = 1; i <= n; ++j, i = j) {
    ++ii;
    while (a[j + 1].a == a[j].a) ++j;
    for (int k = 0; k <= j - i + 1; ++k)
      for (int l = j - i + 1 - k; l < i && l - (j - i + 1 - k) + k <= j; ++l)
        f[ii][l - (j - i + 1 - k) + k] =
            min(f[ii][l - (j - i + 1 - k) + k],
                f[ii - 1][l] + c[i + k - 1] - c[i - 1]);
  }
  long long ma = f[0][1];
  for (int l = 0; l <= n; ++l) ma = min(ma, f[ii][l]);
  return ma <= 0;
}
int main() {
  n = rd();
  for (int i = 1; i <= n; ++i) a[i].a = rd() * 1000;
  for (int i = 1; i <= n; ++i) a[i].b = rd();
  sort(a + 1, a + n + 1);
  long long l = 0, r = a[1].a * 1000, z = r;
  while (l <= r) {
    long long mid = (l + r) / 2;
    if (check(mid))
      z = mid, r = mid - 1;
    else
      l = mid + 1;
  }
  cout << z;
  return 0;
}
