#include <bits/stdc++.h>
using namespace std;
template <class T>
bool uin(T &a, T b) {
  return a > b ? (a = b, true) : false;
}
template <class T>
bool uax(T &a, T b) {
  return a < b ? (a = b, true) : false;
}
const int maxa = 110, maxn = 51;
vector<pair<long long, long long> > a;
long long dp[maxn][maxn];
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.precision(10);
  cout << fixed;
  int n;
  cin >> n;
  a.resize(n);
  for (int i = 0; i < (int)(n); ++i) cin >> a[i].first, a[i].first *= 1000;
  for (int i = 0; i < (int)(n); ++i) cin >> a[i].second;
  sort((a).rbegin(), (a).rend());
  long long L = 0, R = 1.1e11;
  while (R - L > 1) {
    long long M = (L + R) / 2;
    for (int i = 0; i < (int)(n + 1); ++i)
      for (int j = 0; j < (int)(n + 1); ++j) dp[i][j] = 1e18;
    dp[0][0] = 0.0;
    for (int i = 0; i < n;) {
      int j = i;
      while (j < n && a[i].first == a[j].first) ++j;
      int l = j - i;
      long long total = 0.0;
      for (int z = 0; z < (int)(l + 1); ++z) {
        for (int k = 0; k < (int)(n + 1); ++k)
          if (dp[i][k] < 1e17 && k >= l - z)
            uin(dp[j][k - (l - z) + z], dp[i][k] + total);
        if (z < l) total += a[i + z].first - a[i + z].second * M;
      }
      i = j;
    }
    bool ok = false;
    for (int i = 0; i < (int)(n + 1); ++i) ok |= dp[n][i] <= 0;
    (ok ? R : L) = M;
  }
  cout << R << '\n';
  return 0;
}
