#include <bits/stdc++.h>
using namespace std;
const int N = 55;
int n;
int b[N], id[N];
long long f[N][5010], a[N];
inline int gi() {
  int x = 0, o = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') ch == '-' ? o = -1 : 0, ch = getchar();
  while (ch >= '0' && ch <= '9') x = x * 10 + ch - '0', ch = getchar();
  return o * x;
}
inline long long check(long long k) {
  memset(f, 127, sizeof(f));
  f[0][0] = 0;
  for (int i = 1, la = 0; i <= n; i++) {
    long long A = a[id[i]];
    if (A == a[id[i + 1]])
      memcpy(f[i], f[i - 1], sizeof(f[i]));
    else {
      for (int j = 0; j <= 5000; j++)
        if (f[i - 1][j] < 1LL << 60) {
          long long s = 0;
          for (int p = la; p <= i;) {
            if (j >= i - p)
              f[i][j - i + p + p - la] =
                  min(f[i][j - i + p + p - la], f[i - 1][j] + s);
            s += A - b[id[++p]] * k;
          }
        }
      la = i;
    }
  }
  long long ret = 1LL << 60;
  for (int i = 0; i <= 5000; i++) ret = min(ret, f[n][i]);
  return ret;
}
int main() {
  long long l = 0, r = 0;
  cin >> n;
  for (int i = 1; i <= n; i++) r = max(r, a[i] = 10000LL * gi());
  for (int i = 1; i <= n; i++) b[i] = gi(), id[i] = i;
  sort(id + 1, id + 1 + n, [](const int &x, const int &y) {
    return a[x] == a[y] ? b[x] > b[y] : a[x] > a[y];
  });
  while (l <= r) {
    long long mid = (l + r) >> 1;
    if (check(mid) <= 0)
      r = mid - 1;
    else
      l = mid + 1;
  }
  cout << (l + 9) / 10;
  return 0;
}
