#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3fffffff;
const int SINF = 0x7fffffff;
const long long LINF = 0x3fffffffffffffff;
const long long SLINF = 0x7fffffffffffffff;
const int MINF = 0x3f3f3f3f;
const int MAXN = 53;
const int MAX1 = 103;
const int MAX = MAXN * MAX1 + 207;
const int MUL = 1000;
int n;
pair<int, int> in[MAXN];
long long a[MAXN];
int b[MAXN];
long long dp[2][MAXN][MAX][2];
void init();
void input();
void work();
void chkmin(long long &x, long long y) { x = (((x) < (y)) ? (x) : (y)); }
long long getv(long long x, int y) { return (x + y - 1) / y; }
int main() {
  init();
  input();
  work();
}
void init() { ios::sync_with_stdio(false); }
void input() {
  cin >> n;
  for (int i = 1; i <= n; ++i) cin >> in[i].first;
  for (int i = 1; i <= n; ++i) cin >> in[i].second;
}
void work() {
  sort(in + 1, in + 1 + n, [](const pair<int, int> x, const pair<int, int> y) {
    return (x.first ^ y.first) ? (x.first > y.first) : (x.second < y.second);
  });
  for (int i = 1; i <= n; ++i)
    a[i] = static_cast<long long>(in[i].first) * MUL, b[i] = in[i].second;
  a[0] = LINF;
  a[n + 1] = -LINF;
  for (int t = 0; t < 2; ++t)
    for (int j = 0; j < MAXN; ++j)
      for (int k = 0; k < MAX; ++k) dp[t][j][k][0] = dp[t][j][k][1] = LINF;
  int ub;
  int t = 0;
  dp[t][0][0][0] = 0;
  for (int i = 1; i <= n; ++i) {
    t ^= 1;
    ub = i * MAX1;
    for (int j = 0; j <= i; ++j)
      for (int k = 0; k <= ub; ++k) dp[t][j][k][0] = dp[t][j][k][1] = LINF;
    for (int j = 0; j <= i; ++j) {
      for (int k = 0; k <= ub; ++k) {
        chkmin(dp[t][j][k][0], dp[t ^ 1][j + 1][k][0]);
        if (j && k >= b[i]) {
          chkmin(dp[t][j][k][1], (((dp[t ^ 1][j - 1][k - b[i]][0]) <
                                   (dp[t ^ 1][j - 1][k - b[i]][1]))
                                      ? (dp[t ^ 1][j - 1][k - b[i]][0])
                                      : (dp[t ^ 1][j - 1][k - b[i]][1])) +
                                     a[i]);
        }
      }
    }
    if (a[i] ^ a[i + 1]) {
      for (int j = 0; j <= i; ++j)
        for (int k = 0; k <= ub; ++k) chkmin(dp[t][j][k][0], dp[t][j][k][1]);
    }
  }
  long long ans = LINF;
  for (int i = 0; i <= n; ++i) {
    for (int j = 1; j < MAX; ++j) {
      chkmin(ans,
             getv((((dp[t][i][j][0]) < (dp[t][i][j][1])) ? (dp[t][i][j][0])
                                                         : (dp[t][i][j][1])),
                  j));
    }
  }
  cout << ans << endl;
}
