#include <bits/stdc++.h>
using namespace std;
const int maxn = 55, INF = 1e9;
struct data {
  double a, b;
} t[maxn];
double X, f[maxn][maxn][maxn];
bool vis[maxn][maxn][maxn];
int n;
long long ans;
bool cmp(data a, data b) { return a.a > b.a; }
double dfs(int pos, int d, int g) {
  if (pos > n) return 0;
  if (vis[pos][d][g]) return f[pos][d][g];
  vis[pos][d][g] = 1;
  double tmp = INF;
  if (pos < n && t[pos].a == t[pos + 1].a) {
    if (d) tmp = min(tmp, dfs(pos + 1, d - 1, g));
    tmp = min(tmp, dfs(pos + 1, d, g + 1) + t[pos].a - X * t[pos].b);
  } else if (t[pos].a != t[pos + 1].a || pos == n) {
    if (d) tmp = min(tmp, dfs(pos + 1, d + g - 1, 0));
    tmp = min(tmp, dfs(pos + 1, d + g + 1, 0) + t[pos].a - X * t[pos].b);
  }
  return f[pos][d][g] = tmp;
}
bool check(double k) {
  X = k;
  memset(vis, 0, sizeof(vis));
  memset(f, 0, sizeof(f));
  return dfs(1, 0, 0) <= 0;
}
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> t[i].a;
  for (int i = 1; i <= n; i++) cin >> t[i].b;
  sort(t + 1, t + n + 1, cmp);
  double l = 0, r = 1e8;
  while ((r - l) >= 0.000001) {
    double mid = (l + r) / 2;
    if (check(mid))
      r = mid;
    else
      l = mid;
  }
  ans = (ceil)(l * 1000);
  cout << ans << endl;
}
