#include <bits/stdc++.h>
using namespace std;
char getc() {
  char c = getchar();
  while ((c < 'A' || c > 'Z') && (c < 'a' || c > 'z') && (c < '0' || c > '9'))
    c = getchar();
  return c;
}
int gcd(int n, int m) { return m == 0 ? n : gcd(m, n % m); }
int read() {
  int x = 0, f = 1;
  char c = getchar();
  while (c < '0' || c > '9') {
    if (c == '-') f = -1;
    c = getchar();
  }
  while (c >= '0' && c <= '9')
    x = (x << 1) + (x << 3) + (c ^ 48), c = getchar();
  return x * f;
}
int n;
long long f[55][55][55];
struct data {
  long long x, y;
  bool operator<(const data& a) const { return x > a.x || x == a.x && y < a.y; }
} a[55];
bool check(long long k) {
  memset(f, 42, sizeof(f));
  f[0][0][0] = 0;
  for (int i = 1; i <= n; i++) {
    int t = i;
    while (t < n && a[t + 1].x == a[i].x) t++;
    for (int j = i; j <= t; j++) {
      for (int x = 0; x <= n; x++)
        for (int y = 0; y <= n; y++) {
          f[j][x][y] = f[j - 1][x + 1][y];
          if (y)
            f[j][x][y] =
                min(f[j][x][y], f[j - 1][x][y - 1] + a[j].x - k * a[j].y);
        }
    }
    i = t;
    for (int j = n; j >= 0; j--)
      for (int x = 0; x <= j; x++) f[i][j][0] = min(f[i][j][0], f[i][j - x][x]);
  }
  for (int i = 0; i <= n; i++)
    if (f[n][i][0] <= 0) return 1;
  return 0;
}
signed main() {
  n = read();
  for (int i = 1; i <= n; i++) a[i].x = 1000ll * read();
  for (int i = 1; i <= n; i++) a[i].y = read();
  sort(a + 1, a + n + 1);
  long long l = 0, r = 10000000000000000ll, ans;
  while (l <= r) {
    long long mid = l + r >> 1;
    if (check(mid))
      ans = mid, r = mid - 1;
    else
      l = mid + 1;
  }
  cout << ans;
  return 0;
}
