#include <bits/stdc++.h>
using namespace std;
const int N = 50 + 5;
const long long INF = 1e18;
struct Task {
  int p, b;
  bool operator<(const Task &t) const { return p > t.p; }
} task[N];
int n;
double f[2][N][N];
double val[N];
void setV(int t) {
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < N; j++) {
      f[t][i][j] = INF;
    }
  }
}
void update(double &x, double y) {
  if (x > y) {
    x = y;
  }
}
bool check(double thres) {
  for (int i = 1; i <= n; i++) {
    val[i] = task[i].p - thres * task[i].b;
  }
  int t = 0;
  setV(t);
  f[t][0][0] = 0;
  for (int i = 0; i < n; i++) {
    setV(t ^ 1);
    for (int j = 0; j <= n; j++) {
      for (int k = 0; k <= n; k++) {
        if (f[t][j][k] != INF) {
          int nj = 0, nk = 0;
          if (task[i + 1].p == task[i].p) {
            nj = j, nk = k;
          } else {
            nj = j + k, nk = 0;
          }
          update(f[t ^ 1][nj][nk + 1], f[t][j][k] + val[i + 1]);
          if (nj > 0) {
            update(f[t ^ 1][nj - 1][nk], f[t][j][k]);
          }
        }
      }
    }
    t ^= 1;
  }
  double ret = INF;
  for (int i = 0; i <= n; i++) {
    for (int j = 0; j <= n; j++) {
      update(ret, f[t][i][j]);
    }
  }
  return ret <= 0;
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &task[i].p);
  }
  for (int i = 1; i <= n; i++) {
    scanf("%d", &task[i].b);
  }
  sort(task + 1, task + 1 + n);
  double l = 0, r = 1e10;
  while (r - l > 1) {
    double mid = (l + r) / 2;
    if (check(mid)) {
      r = mid;
    } else {
      l = mid;
    }
  }
  long long ans = ceil(r * 1000);
  printf("%lld\n", ans);
  return 0;
}
