#include <bits/stdc++.h>
using namespace std;
const long double inf = 1e18;
const long double eps = 1e-14;
int n;
pair<int, int> a[66];
long double guess;
long double mem[55][55][55];
bool vis[55][55][55];
long double dp(int cur, int take, int now) {
  if (cur == n) {
    return 0;
  }
  if (vis[cur][take][now]) return mem[cur][take][now];
  vis[cur][take][now] = true;
  long double ans = inf;
  if (cur < n - 1 && a[cur].first == a[cur + 1].first) {
    if (take > 0) ans = min(ans, dp(cur + 1, take - 1, now));
    ans = min(
        ans, dp(cur + 1, take, now + 1) + a[cur].first - guess * a[cur].second);
  } else {
    if (take > 0) ans = min(ans, dp(cur + 1, now + take - 1, 0));
    ans = min(ans, dp(cur + 1, now + take + 1, 0) + a[cur].first -
                       guess * a[cur].second);
  }
  return mem[cur][take][now] = ans;
}
int main(int argc, char const* argv[]) {
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i].first;
  }
  for (int i = 0; i < n; i++) {
    cin >> a[i].second;
  }
  sort(a, a + n);
  reverse(a, a + n);
  long double l = 0;
  long double r = 1e10;
  for (int i = 1; i <= 150; i++) {
    long double m = (l + r) / 2;
    guess = m;
    memset(vis, false, sizeof vis);
    if (dp(0, 0, 0) < 0) {
      r = m;
    } else {
      l = m;
    }
  }
  cout << (long long)ceill(l * 1000) << endl;
  return 0;
}
