#include <bits/stdc++.h>
using namespace std;
int i, j, k, n;
pair<int, int> a[60];
long double lo, mi, hi, eps, c[60], dyn[60][60][60];
bool ok(long double thr) {
  for (i = 1; i <= n; i++)
    c[i] = (long double)a[i].first - (long double)a[i].second * thr;
  for (i = 0; i <= n; i++)
    for (j = 0; j <= n; j++)
      for (k = 0; k <= n; k++) dyn[i][j][k] = 1e9;
  dyn[0][0][0] = 0;
  for (i = 1; i <= n; i++) {
    if (a[i].first != a[i - 1].first) {
      for (j = 0; j <= i; j++)
        for (k = 0; k <= i; k++) {
          dyn[i][j + k][1] = min(dyn[i][j + k][1], dyn[i - 1][j][k] + c[i]);
          if ((j + k) > 0)
            dyn[i][j + k - 1][0] = min(dyn[i][j + k - 1][0], dyn[i - 1][j][k]);
        }
    } else {
      for (j = 0; j <= i; j++)
        for (k = 0; k <= i; k++) {
          dyn[i][j][k + 1] = min(dyn[i][j][k + 1], dyn[i - 1][j][k] + c[i]);
          if (j > 0) dyn[i][j - 1][k] = min(dyn[i][j - 1][k], dyn[i - 1][j][k]);
        }
    }
  }
  long double ans = 1;
  for (j = 0; j <= n; j++)
    for (k = 0; k <= n; k++) ans = min(ans, dyn[n][j][k]);
  return (ans <= 0);
}
bool comp(pair<int, int> a, pair<int, int> b) { return a > b; }
int main() {
  cin >> n;
  for (i = 1; i <= n; i++) cin >> a[i].first;
  for (i = 1; i <= n; i++) cin >> a[i].second;
  sort(a + 1, a + n + 1, comp);
  lo = 0;
  hi = 1e9;
  eps = 1e-9;
  while ((hi - lo) > eps) {
    mi = (lo + hi) / 2;
    if (ok(mi))
      hi = mi;
    else
      lo = mi;
  }
  long long ans = lo * 1000;
  cout << ans + 1;
  return 0;
}
