#include <bits/stdc++.h>
using namespace std;
const int maxn = 53;
const long long inf = 0x3f3f3f3f3f3f3f3fLL;
int n;
pair<long long, long long> a[maxn];
long long f[maxn][maxn][maxn];
bool cmp(const pair<long long, long long> &x,
         const pair<long long, long long> &y) {
  return x.first > y.first;
}
bool check(long long m) {
  memset(f, 0x3f, sizeof(f));
  f[0][0][0] = 0;
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j <= i; ++j) {
      for (int k = 0; k + j <= i; ++k) {
        if (f[i][j][k] >= inf) continue;
        if (i > 0 && a[i + 1].first == a[i].first) {
          if (j > 0) f[i + 1][j - 1][k] = min(f[i + 1][j - 1][k], f[i][j][k]);
          f[i + 1][j][k + 1] =
              min(f[i + 1][j][k + 1],
                  f[i][j][k] + a[i + 1].first - m * a[i + 1].second);
        } else {
          f[i + 1][j + k][1] =
              min(f[i + 1][j + k][1],
                  f[i][j][k] + a[i + 1].first - m * a[i + 1].second);
          if (j + k > 0)
            f[i + 1][j + k - 1][0] = min(f[i + 1][j + k - 1][0], f[i][j][k]);
        }
      }
    }
  }
  for (int j = 0; j <= (n >> 1); ++j)
    for (int k = 0; k + j <= (n >> 1); ++k)
      if (f[n][j][k] <= 0) return 1;
  return 0;
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) scanf("%lld", &a[i].first), a[i].first *= 1000;
  for (int i = 1; i <= n; ++i) scanf("%lld", &a[i].second);
  sort(a + 1, a + n + 1, cmp);
  long long l = 0, r = 10000000000000000LL, mid, ans = r;
  while (l <= r) {
    mid = (l + r) / 2.0;
    if (check(mid)) {
      ans = min(ans, mid);
      r = mid - 1;
    } else
      l = mid + 1;
  }
  printf("%lld\n", ans);
  return 0;
}
