#include <bits/stdc++.h>
using namespace std;
const int Mx = 55;
double f[Mx][Mx][Mx];
struct Task {
  double a, b;
} task[Mx];
int n;
long long ans;
bool cmp(Task a, Task b) { return a.a > b.a; }
bool judge(double x) {
  for (int i = 0; i <= n + 1; i++)
    for (int j = 0; j <= n + 1; j++)
      for (int k = 0; k <= n + 1; k++) f[i][j][k] = 5e9;
  f[0][0][0] = 0;
  for (int i = 1; i <= n; i++)
    for (int j = 0; j <= i; j++)
      for (int k = 0; k <= i; k++)
        if (task[i].a < task[i - 1].a) {
          f[i][j][0] =
              min(f[i][j][0], j - k + 1 >= 0 ? f[i - 1][j - k + 1][k] : 5e9);
          f[i][j][1] =
              min(f[i][j][1],
                  j - k >= 0 ? f[i - 1][j - k][k] + task[i].a - x * task[i].b
                             : 5e9);
        } else {
          f[i][j][k] =
              min(f[i - 1][j + 1][k],
                  k - 1 >= 0 ? f[i - 1][j][k - 1] + task[i].a - x * task[i].b
                             : 5e9);
        }
  for (int j = 0; j <= n; j++)
    for (int k = 0; k <= n - j; k++)
      if (f[n][j][k] <= 0) return 1;
  return 0;
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%lf", &task[i].a);
  for (int i = 1; i <= n; i++) scanf("%lf", &task[i].b);
  sort(task + 1, task + 1 + n, cmp);
  task[0].a = -1e8;
  double l = 0, r = 5e9;
  for (int t = 1; t <= 100; t++) {
    double mid = (l + r) / 2;
    if (judge(mid))
      r = mid;
    else
      l = mid;
  }
  ans = ceil(l * 1000);
  printf("%lld", ans);
}
