#include <bits/stdc++.h>
#pragma GCC optimize("O3")
using namespace std;
const int N = 1200031;
int n;
long long dp[2][51][51][5055];
int a[55], b[55];
vector<pair<int, int> > order;
int main() {
  ios_base::sync_with_stdio(0);
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
  }
  for (int i = 1; i <= n; i++) {
    cin >> b[i];
  }
  order.clear();
  for (int i = 1; i <= n; i++) {
    order.push_back(make_pair(a[i], b[i]));
  }
  sort(order.begin(), order.end());
  reverse(order.begin(), order.end());
  for (int from_prev = 0; from_prev <= 50; from_prev++) {
    for (int from_this = 0; from_this <= 50; from_this++) {
      for (int s = 0; s <= 5000; s++) {
        dp[0][from_prev][from_this][s] = dp[1][from_prev][from_this][s] = 1e18;
      }
    }
  }
  dp[0][0][0][0] = 0;
  int l_cut = 0;
  for (int i = 0; i < order.size(); i++) {
    for (int j = 0; j <= i; j++) {
      for (int q = 0; q <= 50; q++) {
        for (int c = 0; c <= i * 100; c++) {
          dp[1 - i % 2][j][q][c] = 1e18;
        }
      }
    }
    for (int prv = 0; prv <= l_cut; prv++) {
      for (int ths = 0; ths <= i - l_cut; ths++) {
        int nw_prv = prv;
        int nw_ths = ths;
        if (i > 0 && order[i].first != order[i - 1].first)
          nw_prv += nw_ths, nw_ths = 0;
        for (int tw = 0; tw <= 100 * i; tw++) {
          if (dp[i % 2][prv][ths][tw] > 1e15) continue;
          dp[1 - i % 2][nw_prv][nw_ths + 1][tw + order[i].second] =
              min(dp[1 - i % 2][nw_prv][nw_ths + 1][tw + order[i].second],
                  dp[i % 2][prv][ths][tw] + order[i].first);
          if (nw_prv > 0)
            dp[1 - i % 2][nw_prv - 1][nw_ths][tw] = min(
                dp[1 - i % 2][nw_prv - 1][nw_ths][tw], dp[i % 2][prv][ths][tw]);
        }
      }
    }
    if (i > 0 && order[i].first != order[i - 1].first) l_cut = i;
  }
  long long ans = 1e18;
  for (int prv = 0; prv <= 50; prv++) {
    for (int here = 0; here <= 50; here++) {
      for (int w = 1; w <= 5000; w++) {
        long long min_cost = dp[n % 2][prv][here][w];
        long long min_aver = min_cost * 1000;
        min_aver = min_aver / w + (min_aver % w > 0);
        ans = min(ans, min_aver);
      }
    }
  }
  cout << ans << endl;
  return 0;
}
