#include <bits/stdc++.h>
using namespace std;
const int MAXN = (int)53;
const int MOD = (int)1e9 + 7;
const int infint = (int)1e9;
const long double eps = (long double)1e-3;
const long long inf = (long long)1e15;
int n;
long long a[MAXN], b[MAXN], id;
long double dp[MAXN][MAXN];
set<long long> S;
unordered_map<long long, long long> M;
vector<long long> v[MAXN];
vector<long double> dragon[MAXN], pref[MAXN];
bool check(long double mid) {
  for (int i = 0; i < id; i++) {
    dragon[i].clear();
    pref[i].clear();
    for (auto u : v[i]) dragon[i].push_back(a[u] - b[u] * mid);
    sort(dragon[i].begin(), dragon[i].end());
    for (auto u : dragon[i]) {
      long double sum = u;
      if (pref[i].size()) sum += pref[i].back();
      pref[i].push_back(sum);
    }
  }
  for (int i = 0; i < MAXN; i++)
    for (int j = 0; j < MAXN; j++) dp[i][j] = inf;
  dp[0][dragon[0].size()] = pref[0].back();
  for (int i = 0; i < id - 1; i++)
    for (int j = 0; j < MAXN; j++)
      for (int k = 0; k <= dragon[i + 1].size(); k++)
        if (j >= pref[i + 1].size() - k) {
          long double sum = dp[i][j];
          if (k) sum += pref[i + 1][k - 1];
          dp[i + 1][j - (pref[i + 1].size() - k) + k] =
              min(dp[i + 1][j - (pref[i + 1].size() - k) + k], sum);
        }
  for (int i = 0; i < MAXN; i++)
    if (dp[id - 1][i] <= 0) return 1;
  return 0;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for (int i = 0; i < n; i++) cin >> a[i];
  for (int i = 0; i < n; i++) cin >> b[i];
  for (int i = 0; i < n; i++) S.insert(a[i]);
  id = S.size() - 1;
  for (auto u : S) M[u] = id--;
  id = S.size();
  for (int i = 0; i < n; i++) v[M[a[i]]].push_back(i);
  long double l = 0, r = 1e9;
  for (int ted = 0; ted < 60; ted++) {
    long double mid = (l + r) / 2;
    if (check(mid))
      r = mid;
    else
      l = mid;
  }
  long double ans = r * 1000;
  if (ans - (long long)ans < eps)
    cout << (long long)ans;
  else
    cout << (long long)ans + 1;
}
