#include <bits/stdc++.h>
using namespace std;
const long long N = 52;
const long long inf = 1e15 + 1;
double dp[N][N][N], val[N];
pair<long long, long long> lis[N];
signed main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  long long n, i, j, k, l;
  double lef = 0, rig = 1e8, mid;
  cin >> n;
  for (i = 1; i <= n; i++) {
    cin >> lis[i].first;
  }
  for (i = 1; i <= n; i++) {
    cin >> lis[i].second;
  }
  sort(lis + 1, lis + 1 + n,
       [&](pair<long long, long long> x, pair<long long, long long> y) {
         return x.first > y.first;
       });
  for (j = 0; j <= n; j++) {
    for (k = 0; k <= n; k++) {
      dp[0][j][k] = inf;
    }
  }
  dp[0][0][0] = 0;
  while (lef + 1e-6 <= rig) {
    mid = (lef + rig) / 2;
    for (i = 1; i <= n; i++) {
      val[i] = lis[i].first - mid * lis[i].second;
      for (j = 0; j <= i; j++) {
        for (k = 0; k <= i - j; k++) {
          dp[i][j][k] = inf;
        }
      }
    }
    for (i = 0; i < n; i++) {
      if (lis[i].first == lis[i + 1].first) {
        for (j = 0; j <= i; j++) {
          for (k = 0; k <= i - j; k++) {
            if (j) {
              dp[i + 1][j - 1][k] = min(dp[i + 1][j - 1][k], dp[i][j][k]);
            }
            dp[i + 1][j][k + 1] =
                min(dp[i + 1][j][k + 1], dp[i][j][k] + val[i + 1]);
          }
        }
      } else {
        for (j = 0; j <= i; j++) {
          for (k = 0; k <= i - j; k++) {
            if (j + k) {
              dp[i + 1][j + k - 1][0] =
                  min(dp[i + 1][j + k - 1][0], dp[i][j][k]);
            }
            dp[i + 1][j + k][1] =
                min(dp[i + 1][j + k][1], dp[i][j][k] + val[i + 1]);
          }
        }
      }
    }
    bool cac = true;
    for (i = 0; i <= n; i++) {
      for (j = 0; j <= n - i; j++) {
        if (dp[n][i][j] <= 0) {
          cac = false;
          rig = mid;
          break;
        }
      }
      if (!cac) {
        break;
      }
    }
    if (cac) {
      lef = mid;
    }
  }
  j = rig * 1000;
  k = rig * 1000000;
  if (k == j * 1000) {
    cout << j;
  } else {
    cout << j + 1;
  }
}
