#include <bits/stdc++.h>
using namespace std;
const int inf = 1e9;
const long long Inf = 1e18;
const int N = 60;
int gi() {
  int x = 0, o = 1;
  char ch = getchar();
  while ((ch < '0' || ch > '9') && ch != '-') ch = getchar();
  if (ch == '-') o = -1, ch = getchar();
  while (ch >= '0' && ch <= '9') x = x * 10 + ch - '0', ch = getchar();
  return x * o;
}
template <typename T>
void chkmax(T &a, T b) {
  a < b ? a = b : 0;
};
template <typename T>
void chkmin(T &a, T b) {
  a > b ? a = b : 0;
};
struct data {
  long long a;
  int b;
  bool operator<(const data &rhs) const {
    if (a == rhs.a) return b < rhs.b;
    return a > rhs.a;
  }
} p[N];
int n;
long long w[N], sum[N], f[N][N];
bool check(long long mid) {
  for (int i = 1; i <= n; i++)
    w[i] = p[i].a - mid * p[i].b, sum[i] = sum[i - 1] + w[i];
  memset(f, 0x3f, sizeof(f));
  f[0][0] = 0;
  for (int i = 1, j; i <= n; i = j + 1) {
    j = i;
    while (j + 1 <= n && p[j + 1].a == p[i].a) j++;
    for (int k = 0; k < i; k++)
      for (int l = i; l <= j + 1 && l - i <= k; l++)
        chkmin(f[j][k - (l - i) + (j - l + 1)],
               f[i - 1][k] + sum[j] - sum[l - 1]);
  }
  for (int i = 0; i <= n; i++)
    if (f[n][i] <= 0) return 1;
  return 0;
}
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) p[i].a = 1000ll * gi();
  for (int i = 1; i <= n; i++) p[i].b = gi();
  sort(p + 1, p + n + 1);
  long long l = 0, r = 1e13, ret = 0;
  while (l <= r) {
    long long mid = (l + r) >> 1;
    if (check(mid))
      ret = mid, r = mid - 1;
    else
      l = mid + 1;
  }
  printf("%lld\n", ret);
  return 0;
}
