#include <bits/stdc++.h>
using namespace std;
const long long inf = 1e18, maxb = 101;
void upd(long long& a, long long b) { a = min(a, b); }
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<pair<long long, long long> > v(n);
  for (int i = 0; i < n; i++) cin >> v[i].first;
  for (int i = 0; i < n; i++) cin >> v[i].second;
  sort(v.begin(), v.end(), greater<pair<long long, long long> >());
  vector<vector<vector<long long> > > dp(
      n + 1,
      vector<vector<long long> >(n + 1, vector<long long>(n * maxb + 1, inf)));
  dp[0][0][0] = 0;
  int last = 0;
  for (int i = 1; i <= n; i++) {
    if (i == n || v[i - 1].first != v[i].first) {
      for (int free = 0; free <= last; free++) {
        long long sumup = 0, sumdown = 0;
        for (int one = 0; one <= i - last; one++) {
          for (int d = 0; d <= last * maxb; d++) {
            if (free >= i - last - one) {
              upd(dp[i][free - (i - last - one) + one][d + sumdown],
                  dp[last][free][d] + sumup);
            }
          }
          if (one < i - last) {
            sumup += v[last + one].first;
            sumdown += v[last + one].second;
          }
        }
      }
      last = i;
    }
  }
  long long ans = inf;
  for (long long free = 0; free <= n; free++) {
    for (long long d = 1; d < dp[n][free].size(); d++) {
      if (dp[n][free][d] == inf) continue;
      ans = min(ans, (dp[n][free][d] * 1000ll + d - 1) / d);
    }
  }
  cout << ans << "\n";
  return 0;
}
