#include <bits/stdc++.h>
using namespace std;
const int N = 55;
int n;
int a[N], b[N];
double LIM;
bool vis[N][N][N];
double dp[N][N][N];
double solve(int pos, int taken_small, int taken_eq) {
  if (pos > n) return 0.0;
  if (vis[pos][taken_small][taken_eq]) return dp[pos][taken_small][taken_eq];
  double ans;
  if (a[pos] != a[pos + 1]) {
    ans = a[pos] - LIM * b[pos] + solve(pos + 1, taken_small + taken_eq + 1, 0);
    int not_taken = pos - taken_small - taken_eq;
    if (not_taken <= taken_small)
      ans = min(ans, solve(pos + 1, taken_small + taken_eq, 0));
  } else {
    ans = a[pos] - LIM * b[pos] + solve(pos + 1, taken_small, taken_eq + 1);
    int not_taken = pos - taken_small - taken_eq;
    if (not_taken <= taken_small)
      ans = min(ans, solve(pos + 1, taken_small, taken_eq));
  }
  vis[pos][taken_small][taken_eq] = true;
  return dp[pos][taken_small][taken_eq] = ans;
}
bool ok(double lim) {
  LIM = lim;
  memset(vis, 0, sizeof vis);
  double ans = solve(1, 0, 0);
  return ans <= 0.0;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cin >> n;
  vector<pair<int, int>> vec;
  for (int i = 1; i <= n; i++) cin >> a[i];
  for (int i = 1; i <= n; i++) cin >> b[i];
  for (int i = 1; i <= n; i++) {
    vec.push_back({a[i], b[i]});
  }
  sort(vec.rbegin(), vec.rend());
  for (int i = 0; i < n; i++) {
    a[i + 1] = vec[i].first;
    b[i + 1] = vec[i].second;
  }
  double lo = 0, hi = 1e8;
  for (int itr = 1; itr <= 60; itr++) {
    double mid = (lo + hi) * 0.5;
    if (ok(mid))
      hi = mid;
    else
      lo = mid;
  }
  long long ans = ceil(lo * 1000);
  cout << ans << endl;
  return 0;
}
