#include <bits/stdc++.h>
using namespace std;
const long long maxn = 5e1 + 10;
const long long base = 3e18;
const long long mod = 1e9 + 7;
const long double eps = 1e-10;
long long dp[maxn][maxn][maxn];
pair<long long, long long> a[maxn];
long long n;
bool chk(long long mid) {
  for (int i = 0; i <= n; i++) {
    for (int j = 0; j <= n; j++) {
      for (int k = 0; k <= n; k++) {
        dp[i][j][k] = base;
      }
    }
  }
  dp[0][0][0] = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j <= n; j++) {
      for (int k = 0; k <= n; k++) {
        if (a[i + 1].first == a[i].first) {
          if (j) {
            dp[i + 1][j - 1][k] = min(dp[i + 1][j - 1][k], dp[i][j][k]);
          }
          dp[i + 1][j][k + 1] =
              min(dp[i + 1][j][k + 1],
                  dp[i][j][k] + (a[i + 1].first - a[i + 1].second * mid));
        } else {
          long long nxt = j + k;
          if (nxt) {
            dp[i + 1][nxt - 1][0] = min(dp[i + 1][nxt - 1][0], dp[i][j][k]);
          }
          dp[i + 1][nxt][1] =
              min(dp[i + 1][nxt][1],
                  dp[i][j][k] + (a[i + 1].first - a[i + 1].second * mid));
        }
      }
    }
  }
  for (int j = 0; j <= n; j++) {
    for (int k = 0; k <= n; k++) {
      if (dp[n][j][k] <= 0) return true;
    }
  }
  return false;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  if (fopen("t.inp", "r")) {
    freopen("test.inp", "r", stdin);
    freopen("test.out", "w", stdout);
  }
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i].first;
    a[i].first *= 1000;
  }
  for (int i = 1; i <= n; i++) {
    cin >> a[i].second;
  }
  sort(a + 1, a + n + 1);
  reverse(a + 1, a + n + 1);
  long long l = 0, h = 1e14;
  while (l <= h) {
    long long mid = (l + h) / 2;
    if (chk(mid))
      h = mid - 1;
    else
      l = mid + 1;
  }
  cout << l << "\n";
}
