#include <bits/stdc++.h>
using namespace std;
const int N = 51;
const long long MOD = 1e9 + 7;
const double eps = 1e-8;
int n, a[N], b[N];
vector<pair<int, int> > v;
double dp[N][N][N], thresh;
bool vis[N][N][N];
double calc(int i, int g, int e) {
  if (i == n) return 0.0;
  double &r = dp[i][g][e];
  if (vis[i][g][e]) return r;
  vis[i][g][e] = 1;
  int g2 = g, e2 = e;
  if (i && v[i].first != v[i - 1].first) {
    g2 += e2;
    e2 = 0;
  }
  r = calc(i + 1, g2, e2 + 1) + v[i].first - thresh * v[i].second;
  if (g2) r = min(r, calc(i + 1, g2 - 1, e2));
  return r;
}
bool check(double m) {
  memset(vis, 0, sizeof vis);
  thresh = m;
  double r = calc(0, 0, 0);
  return !(r > eps);
}
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) scanf("%d", a + i);
  for (int i = 0; i < n; i++) {
    scanf("%d", b + i);
    v.push_back(make_pair(a[i], b[i]));
  }
  sort(v.begin(), v.end());
  reverse(v.begin(), v.end());
  double l = 0, r = 5e9 + 1, m, ans = 0.0;
  int it = 80;
  while (l < r && it) {
    m = (l + r) / 2;
    it--;
    if (check(m)) {
      ans = m;
      r = m;
    } else
      l = m;
  }
  printf("%.0lf\n", ceil(ans * 1000));
  return 0;
}
