#include <bits/stdc++.h>
using namespace std;
long long dp[2][50 * 100][51];
pair<int, int> vec[50];
vector<pair<int, int> > x;
struct node {
  int ks;
  int bs;
  long long vsum;
};
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) scanf("%d", &vec[i].first);
  for (int i = 0; i < n; i++) scanf("%d", &vec[i].second);
  sort(vec, vec + n, greater<pair<int, int> >());
  int cnt = 0;
  for (int i = 0; i < n; i++) {
    if (i && vec[i].first != vec[i - 1].first) {
      x.push_back({i - cnt, i - 1});
      cnt = 0;
    }
    cnt++;
  }
  x.push_back({n - cnt, n - 1});
  int nn = (int)(x).size();
  memset(dp, 0x3f, sizeof(dp));
  dp[0][0][0] = 0;
  int sum = 0;
  cnt = 0;
  for (int i = 0; i < nn; i++) {
    memset(dp[i & 1 ^ 1], 0x3f, sizeof(dp[i & 1 ^ 1]));
    int nc = x[i].second - x[i].first + 1;
    int le = x[i].first, ri = x[i].second;
    for (int j = 0; j <= cnt; j++) {
      vector<node> v;
      for (int ajr = 0; ajr <= min(j, nc); ajr++) {
        long long vs = 0;
        int bs = 0, ks = 0;
        for (int k = le; k <= ri; k++) {
          if (ri - k <= ajr - 1)
            ks--;
          else {
            vs += vec[k].first;
            bs += vec[k].second;
            ks++;
          }
        }
        v.push_back({ks, bs, vs});
      }
      for (node now : v) {
        for (int ss = 0; ss <= sum; ss++) {
          if (ss + now.bs > 5000 || j + now.ks < 0 || j + now.ks > 50) break;
          dp[i & 1 ^ 1][now.bs + ss][j + now.ks] =
              min(dp[i & 1 ^ 1][now.bs + ss][j + now.ks],
                  dp[i & 1][ss][j] + now.vsum);
        }
      }
    }
    for (int j = le; j <= ri; j++) sum += vec[j].second;
    cnt += x[i].second - x[i].first + 1;
  }
  long double ans = 1e18;
  for (int j = 0; j <= sum; j++)
    for (int k = 0; k <= n; k++) {
      ans = min(ans, (long double)dp[nn & 1][j][k] / j);
    }
  long long tt = (ans - (1E-8)) * 1000;
  printf("%lld", tt + 1);
}
