#include <bits/stdc++.h>
using namespace std;
int n;
double f[55][55][55];
struct node {
  double a, b;
  bool operator<(const node &p) const { return a > p.a; }
} t[55];
bool check(double ans) {
  for (int i = 0; i <= n; i++)
    for (int j = 0; j <= n; j++)
      for (int k = 0; k <= n; k++) f[i][j][k] = 9999999999999999.0;
  double res = 9999999999999999.0;
  f[0][0][0] = 0;
  for (int i = 0; i < n; i++)
    for (int j = 0; j <= i; j++)
      for (int k = 0; j + k <= i; k++) {
        if (f[i][j][k] == 9999999999999999.0) continue;
        if (t[i].a == t[i + 1].a) {
          f[i + 1][j][k + 1] = min(f[i + 1][j][k + 1],
                                   f[i][j][k] + t[i + 1].a - ans * t[i + 1].b);
          if (j) f[i + 1][j - 1][k] = min(f[i + 1][j - 1][k], f[i][j][k]);
        } else {
          f[i + 1][j + k][1] = min(f[i + 1][j + k][1],
                                   f[i][j][k] + t[i + 1].a - ans * t[i + 1].b);
          if (j + k)
            f[i + 1][j + k - 1][0] = min(f[i + 1][j + k - 1][0], f[i][j][k]);
        }
      }
  for (int i = 0; i <= n; i++)
    for (int j = 0; i + j <= n; j++) res = min(res, f[n][i][j]);
  return res < 1e-5;
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%lf", &t[i].a);
  for (int i = 1; i <= n; i++) scanf("%lf", &t[i].b);
  sort(t + 1, t + n + 1);
  double l = 0, r = t[1].a;
  while (r - l > 1e-5) {
    double mid = (l + r) * 0.5;
    if (check(mid))
      r = mid;
    else
      l = mid;
  }
  printf("%I64d\n", (long long)ceil(l * 1000));
  return 0;
}
