#include <bits/stdc++.h>
using namespace std;
const double PI = acos(-1);
const long long INF = 1e13;
const int MAXN = 51;
long long dp[MAXN][MAXN][MAXN * 100];
int main() {
  std::ios_base::sync_with_stdio(false);
  std::cin.tie(0);
  int n;
  cin >> n;
  vector<long long> a(n), b(n);
  vector<pair<long long, long long>> p(n);
  for (int i = 0; i < n; ++i) {
    cin >> p[i].first;
  }
  for (int i = 0; i < n; ++i) {
    cin >> p[i].second;
  }
  sort((p).begin(), (p).end());
  reverse((p).begin(), (p).end());
  for (int i = 0; i < n; ++i) {
    a[i] = p[i].first;
    b[i] = p[i].second;
  }
  for (int i = 0; i <= n; ++i) {
    for (int j = 0; j <= i; ++j) {
      for (int k = 0; k <= 100 * (i - j); ++k) {
        dp[i][j][k] = INF;
      }
    }
  }
  dp[0][0][0] = 0;
  for (int i = 0; i < n;) {
    int rg = i;
    for (; rg < n && a[rg] == a[i]; ++rg)
      ;
    int len = rg - i;
    long long x = a[i];
    long long sum = 0;
    for (int u = i; u < rg; ++u) {
      sum += b[u];
    }
    for (int j = 0; j <= i; ++j) {
      for (int k = 0; k <= 100 * (i - j); ++k) {
        if (dp[i][j][k] == INF) {
          continue;
        }
        long long s = 0;
        for (int u = 0; u <= len; ++u) {
          if (j + u > i - j) {
            continue;
          }
          dp[rg][j + u][k + sum - s] =
              min(dp[rg][j + u][k + sum - s], dp[i][j][k] + (len - u) * x);
          if (u < len) {
            s += b[rg - 1 - u];
          }
        }
      }
    }
    i = rg;
  }
  long long ans = INF;
  for (int j = 0; j <= n; ++j) {
    for (int k = 1; k <= 100 * (n - j); ++k) {
      if (dp[n][j][k] < INF) {
        ans = min(ans, (dp[n][j][k] * 1000 + k - 1) / k);
      }
    }
  }
  cout << ans << endl;
  return 0;
}
