#include <bits/stdc++.h>
using namespace std;
const long double eps = 1e-5, inf = 1e15;
signed main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int64_t n;
  cin >> n;
  int64_t a[n], b[n];
  for (int64_t i = 0; i < n; i++) {
    cin >> a[i];
  }
  for (int64_t i = 0; i < n; i++) {
    cin >> b[i];
  }
  int64_t p[n];
  iota(p, p + n, 0);
  sort(p, p + n, [&](int64_t x, int64_t y) { return a[x] > a[y]; });
  long double l = 0, r = 1e9;
  for (int64_t z = 0; z < 200; z++) {
    long double m = (l + r) / 2;
    long double ta[n];
    for (int64_t i = 0; i < n; i++) {
      ta[i] = a[i] - m * b[i];
    }
    long double dp[n + 1];
    fill(dp, dp + n + 1, inf);
    dp[0] = 0;
    long double tdp[n + 1];
    fill(tdp, tdp + n + 1, inf);
    tdp[0] = 0;
    int64_t cur = 0;
    for (int64_t i = 0; i < n; i++) {
      long double ndp[n + 1];
      fill(ndp, ndp + n + 1, inf);
      for (int64_t j = 0; j <= cur; j++) {
        ndp[j] = min(ndp[j], tdp[j] + ta[p[i]]);
        ndp[j + 1] = min(ndp[j + 1], tdp[j]);
      }
      copy(ndp, ndp + n + 1, tdp);
      cur++;
      if (i + 1 == n || a[p[i]] != a[p[i + 1]]) {
        long double ndp[n + 1];
        fill(ndp, ndp + n + 1, inf);
        for (int64_t i = 0; i <= n; i++) {
          for (int64_t j = 0; j <= min(i, cur); j++) {
            ndp[i - j + (cur - j)] =
                min(ndp[i - j + (cur - j)], dp[i] + tdp[j]);
          }
        }
        copy(ndp, ndp + n + 1, dp);
        fill(tdp, tdp + n + 1, inf);
        tdp[0] = 0;
        cur = 0;
      }
    }
    long double mn = *min_element(dp, dp + n + 1);
    if (mn <= 0) {
      r = m;
    } else {
      l = m;
    }
  }
  long double ans = l * 1000;
  int64_t ansi;
  if (abs(ans - llround(ans)) < eps) {
    ansi = llround(ans);
  } else {
    ansi = llround(ceil(ans));
  }
  cout << ansi << endl;
}
