#include <bits/stdc++.h>
using namespace std;
const int maxn = 55;
int n;
double f[55][55];
pair<int, int> p[maxn];
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &p[i].first);
  }
  for (int i = 1; i <= n; i++) {
    scanf("%d", &p[i].second);
  }
  double st = clock();
  sort(p + 1, p + n + 1);
  auto chk = [&](double x) {
    for (int i = 0; i <= n; i++) {
      for (int j = 0; j <= n; j++) f[i][j] = 1e18;
    }
    f[0][0] = 0;
    for (int i = 1; i <= n; i++) {
      double w = p[i].first - x * p[i].second;
      for (int j = 0; j < i; j++) {
        int c0 = 0, c1 = 0;
        for (int k = j + 1; k < i; k++) {
          if (p[i].first == p[k].first)
            c0++;
          else
            c1++;
        }
        for (int k = 0; k <= j; k++) {
          int nk = max(0, k + c1 - 1) + c0;
          f[i][nk] = min(f[i][nk], f[j][k] + w);
        }
      }
    }
    return f[n][0] <= 0;
  };
  double l = 0, r = 1e8;
  while ((clock() - st) / CLOCKS_PER_SEC < 0.7) {
    double mid = (l + r) / 2;
    chk(mid) ? r = mid : l = mid;
  }
  printf("%lld\n", (long long)ceil(r * 1000 - 1e-9));
  return 0;
}
