#include <bits/stdc++.h>
using namespace std;
pair<int, int> p[55];
long long dp[2][55][50005];
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", &p[i].first);
  for (int i = 1; i <= n; i++) scanf("%d", &p[i].second);
  sort(p + 1, p + n + 1);
  for (int i = 0; i <= n; i++)
    for (int j = 0; j <= 100 * n; j++) dp[0][i][j] = 1e18;
  dp[0][0][0] = 0;
  int r = n;
  int cur = 1;
  for (int ind = n; ind >= 1; ind--) {
    if (p[ind].first != p[ind + 1].first) r = ind;
    if (p[ind - 1].first == p[ind].first) continue;
    int sum = 0;
    for (int x = ind; x <= r; x++) sum += p[x].second;
    for (int i = 0; i <= n; i++)
      for (int j = 0; j <= 100 * n; j++) dp[cur][i][j] = 1e18;
    for (int take = 0; take <= r - ind + 1; take++) {
      int add = (r - ind + 1) - 2 * take;
      for (int x = n; x >= 0; x--) {
        if (x - add < take) continue;
        if (x - add > n) continue;
        for (int y = 100 * n; y >= sum; y--) {
          dp[cur][x][y] =
              min(dp[cur][x][y], dp[!cur][x - add][y - sum] +
                                     1LL * (r - ind + 1 - take) * p[ind].first);
        }
      }
      sum -= p[ind + take].second;
    }
    cur = !cur;
  }
  long double res = 1e18;
  for (int i = 0; i <= n; i++)
    for (int j = 1; j <= 100 * n; j++)
      res = min(res, (long double)dp[!cur][i][j] / j);
  printf("%lld", (long long)(res * 1000 + 0.999));
  return 0;
}
