#include <bits/stdc++.h>
clock_t t = clock();
namespace my_std {
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
template <typename T>
inline T rnd(T l, T r) {
  return uniform_int_distribution<T>(l, r)(rng);
}
template <typename T>
inline bool chkmax(T &x, T y) {
  return x < y ? x = y, 1 : 0;
}
template <typename T>
inline bool chkmin(T &x, T y) {
  return x > y ? x = y, 1 : 0;
}
template <typename T>
inline void read(T &t) {
  t = 0;
  char f = 0, ch = getchar();
  double d = 0.1;
  while (ch > '9' || ch < '0') f |= (ch == '-'), ch = getchar();
  while (ch <= '9' && ch >= '0') t = t * 10 + ch - 48, ch = getchar();
  if (ch == '.') {
    ch = getchar();
    while (ch <= '9' && ch >= '0') t += d * (ch ^ 48), d *= 0.1, ch = getchar();
  }
  t = (f ? -t : t);
}
template <typename T, typename... Args>
inline void read(T &t, Args &...args) {
  read(t);
  read(args...);
}
char sr[1 << 21], z[20];
int C = -1, Z = 0;
inline void Ot() { fwrite(sr, 1, C + 1, stdout), C = -1; }
inline void print(register int x) {
  if (C > 1 << 20) Ot();
  if (x < 0) sr[++C] = '-', x = -x;
  while (z[++Z] = x % 10 + 48, x /= 10)
    ;
  while (sr[++C] = z[Z], --Z)
    ;
  sr[++C] = '\n';
}
void file() {}
inline void chktime() {}
long long ksm(long long x, int y) {
  long long ret = 1;
  for (; y; y >>= 1, x = x * x)
    if (y & 1) ret = ret * x;
  return ret;
}
}  // namespace my_std
using namespace my_std;
int n;
struct hh {
  long long a, b;
  inline bool operator<(const hh &y) const { return a > y.a; }
} a[100];
vector<double> w[100], sum[100];
int c[100];
double dp[100][100];
bool judge(double W) {
  int cnt = 0;
  for (int i = (1); i <= (n); i++) w[i].resize(0), sum[i].resize(0);
  for (int i = (1); i <= (n); i++) {
    if (i == 1 || a[i].a != a[i - 1].a) ++cnt;
    w[cnt].push_back(a[i].a - W * a[i].b);
  }
  for (int i = (1); i <= (cnt); i++) {
    sort(w[i].begin(), w[i].end());
    sum[i].resize(w[i].size());
    sum[i][0] = w[i][0];
    c[i] = c[i - 1] + w[i].size();
    for (int j = (1); j <= ((int)sum[i].size() - 1); j++)
      sum[i][j] = sum[i][j - 1] + w[i][j];
  }
  for (int i = (0); i <= (n); i++)
    for (int j = (0); j <= (c[cnt]); j++) dp[i][j] = 1e9;
  dp[0][0] = 0;
  for (int i = (1); i <= (cnt); i++)
    for (int j = (1); j <= (c[i]); j++)
      if (j * 2 >= c[i]) {
        dp[i][j] = dp[i - 1][j];
        for (int k = (1); k <= (min(j, c[i] - c[i - 1])); k++)
          if ((j - k) * 2 >= c[i] - c[i - 1] - k)
            chkmin(dp[i][j], dp[i - 1][j - k] + sum[i][k - 1]);
      }
  double ret = 1e9;
  for (int i = (1); i <= (n); i++) chkmin(ret, dp[cnt][i]);
  return ret <= 0;
}
int main() {
  file();
  read(n);
  for (int i = (1); i <= (n); i++) read(a[i].a);
  for (int i = (1); i <= (n); i++) read(a[i].b);
  sort(a + 1, a + n + 1);
  double l = 0, r = 1e10, ans = 0;
  while (r - l >= 1e-7) {
    double mid = (l + r) / 2;
    if (judge(mid))
      ans = r = mid;
    else
      l = mid;
  }
  printf("%lld", (long long)ceil((ans - 1e-5) * 1000));
  return 0;
}
