#include <bits/stdc++.h>
using namespace std;
struct node {
  int p, q;
  double r;
};
node a[55];
int n;
short flag[55][55][55];
double dp[55][55][55];
double solve(int index, int count1, int count2) {
  if (index == n) return 0;
  if (flag[index][count1][count2] != -1) return dp[index][count1][count2];
  double res = DBL_MAX;
  if (index > 0 && a[index].p < a[index - 1].p) {
    res = min(res, a[index].r + solve(index + 1, count1 + count2, 1));
    if ((count1 + count2) > 0)
      res = min(res, solve(index + 1, count1 + count2 - 1, 0));
  } else {
    res = min(res, a[index].r + solve(index + 1, count1, count2 + 1));
    if (count1 > 0) res = min(res, solve(index + 1, count1 - 1, count2));
  }
  dp[index][count1][count2] = res;
  flag[index][count1][count2] = 0;
  return res;
}
bool calc() {
  double res = solve(0, 0, 0);
  if (res > 0)
    return false;
  else
    return true;
}
bool cmp(node a, node b) {
  if (a.p != b.p)
    return a.p > b.p;
  else
    return a.q >= b.q;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for (int i = 0; i < (n); ++i) cin >> a[i].p;
  for (int i = 0; i < (n); ++i) cin >> a[i].q;
  sort(a, a + n, cmp);
  double lo = 0, hi = 1e9;
  for (int i = 0; i < (100); ++i) {
    double mid = lo + (hi - lo) / 2;
    int c[n];
    for (int i = 0; i < (n); ++i) a[i].r = a[i].p - mid * a[i].q;
    memset(flag, -1, sizeof(flag));
    if (calc())
      hi = mid;
    else
      lo = mid;
  }
  long long ans = ceil(lo * 1000);
  cout << ans;
  return 0;
}
