#include <bits/stdc++.h>
using namespace std;
const int N = 205;
const double INF = 1e16, eps = 1e-6;
int n, id[N], a[N], b[N];
double c[N], ans, f[N][N][N], g[N][N];
int getint() {
  char ch;
  int f = 1;
  while (!isdigit(ch = getchar()))
    if (ch == '-') f = -1;
  int x = ch - 48;
  while (isdigit(ch = getchar())) x = x * 10 + ch - 48;
  return x * f;
}
bool check(double x) {
  for (int i = 1; i <= n; ++i) c[i] = a[i] - b[i] * x;
  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] = INF;
  f[0][0][0] = 0;
  for (int i = 0; i <= n - 1; ++i) {
    int x = id[i + 1];
    if (i && a[id[i]] != a[id[i + 1]]) {
      for (int j = 0; j <= n; ++j)
        for (int k = 0; k <= n; ++k) g[j][k] = f[i][j][k], f[i][j][k] = INF;
      for (int j = 0; j <= n; ++j)
        for (int k = 0; k <= n; ++k)
          f[i][j + k][0] = min(f[i][j + k][0], g[j][k]);
    }
    for (int j = 0; j <= n; ++j)
      for (int k = 0; k <= n; ++k) {
        f[i + 1][j][k + 1] = min(f[i + 1][j][k + 1], f[i][j][k] + c[x]);
        if (j) f[i + 1][j - 1][k] = min(f[i + 1][j - 1][k], f[i][j][k]);
      }
  }
  ans = INF;
  for (int i = 0; i <= n; ++i)
    for (int j = 0; j <= n; ++j) ans = min(ans, f[n][i][j]);
  return ans + eps < 0;
}
bool cmp(int x, int y) { return a[x] > a[y]; }
int main() {
  n = getint();
  for (int i = 1; i <= n; ++i) a[i] = getint();
  for (int i = 1; i <= n; ++i) b[i] = getint();
  for (int i = 1; i <= n; ++i) id[i] = i;
  sort(id + 1, id + 1 + n, cmp);
  double l = 0, r = 100000000;
  while (l + eps < r) {
    double mid = (l + r) / 2;
    if (check(mid))
      r = mid;
    else
      l = mid;
  }
  l = l * 1000;
  long long GG = (long long)l;
  if ((l -= GG) >= (1e-2)) ++GG;
  printf("%lld\n", GG);
  return 0;
}
