#include <bits/stdc++.h>
using namespace std;
const int N = 5e5;
const long double eps = 1e-9;
pair<int, int> a[N];
int n;
int f[N];
long long dp[5001][51];
long long ndp[5001][51];
int main() {
  ios_base::sync_with_stdio(0);
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> a[i].first;
  for (int i = 1; i <= n; i++) cin >> a[i].second;
  for (int i = 1; i <= n; i++) a[i].second = -a[i].second;
  sort(a + 1, a + n + 1);
  reverse(a + 1, a + n + 1);
  for (int i = 1; i <= n; i++) a[i].second = -a[i].second;
  for (int i = 1; i <= n; i++) f[i] = f[i - 1] + a[i].second;
  int l = 1;
  for (int i = 0; i <= 5000; i++)
    for (int j = 0; j <= n; j++) dp[i][j] = 1e18;
  dp[0][0] = 0;
  while (l <= n) {
    for (int i = 0; i <= 5000; i++)
      for (int j = 0; j <= n; j++) ndp[i][j] = 1e18;
    int r = l;
    while (r <= n && a[r].first == a[l].first) r++;
    for (int i = 0; i <= 5000; i++)
      for (int j = 0; j <= n; j++)
        if (dp[i][j] != 1e18) {
          for (int t = 0; t <= min(r - l, j); t++)
            ndp[i + f[r - 1] - f[l - 1 + t]][j + (r - l) - 2 * t] =
                min(ndp[i + f[r - 1] - f[l - 1 + t]][j + (r - l) - 2 * t],
                    (r - l - t) * a[l].first + dp[i][j]);
        }
    l = r;
    for (int i = 0; i <= 5000; i++)
      for (int j = 0; j <= n; j++) dp[i][j] = ndp[i][j];
  }
  long double ans = 1e9;
  for (int i = 1; i <= 5000; i++)
    for (int j = 0; j <= n; j++)
      if (dp[i][j] != 1e18) ans = min(ans, (long double)(1.0 * dp[i][j] / i));
  ans *= 1000;
  long long rr = ans;
  if (abs(rr - ans) > eps) rr++;
  cout << rr << "\n";
  return 0;
}
