#include <bits/stdc++.h>
using namespace std;
int n;
int a[60], b[60];
double dp[120][120][120];
bool check(double threshold) {
  for (int i = 0; i < 59; i++)
    for (int j = 0; j < 59; j++)
      for (int k = 0; k < 59; k++) dp[i][j][k] = 1e9;
  dp[1][0][1] = double(a[1]) - threshold * double(b[1]);
  for (int i = 1; i < n; i++) {
    for (int higher = 0; higher <= n; higher++) {
      for (int same = 0; same <= n; same++) {
        int higher1, same1;
        if (a[i + 1] < a[i]) {
          higher1 = higher + same;
          same1 = 0;
        } else {
          higher1 = higher;
          same1 = same;
        }
        if (higher1 > 0) {
          dp[i + 1][higher1 - 1][same1] =
              min(dp[i + 1][higher1 - 1][same1], dp[i][higher][same]);
        }
        dp[i + 1][higher1][same1 + 1] =
            min(dp[i + 1][higher1][same1 + 1],
                dp[i][higher][same] + double(a[i + 1]) -
                    threshold * double(b[i + 1]));
      }
    }
  }
  double res = 1e9;
  for (int higher = 0; higher <= n; higher++)
    for (int same = 0; same <= n; same++) res = min(res, dp[n][higher][same]);
  return res <= 0.;
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  for (int i = 1; i <= n; i++) scanf("%d", &b[i]);
  vector<pair<int, int> > tmp;
  for (int i = 1; i <= n; i++) tmp.emplace_back(a[i], b[i]);
  sort(tmp.begin(), tmp.end(), greater<pair<int, int> >());
  a[0] = 1e9;
  for (int i = 1; i <= n; i++) {
    a[i] = tmp[i - 1].first;
    b[i] = tmp[i - 1].second;
  }
  double pocz = 0., kon = 1e9, mid;
  for (int i = 0; i < 100; i++) {
    mid = (pocz + kon) / 2.;
    if (check(mid))
      kon = mid;
    else
      pocz = mid;
  }
  printf("%I64d\n", (long long)(ceil(pocz * 1000.)));
  return 0;
}
