#include <bits/stdc++.h>
using namespace std;
int a[55], b[55], r[55], n;
bool cmp(int i, int j) {
  if (a[i] > a[j])
    return true;
  else
    return false;
}
double c[55], f[55][55][55];
int w[55];
bool judge(double k) {
  for (int i = 0; i <= n; i++) {
    for (int j = 0; j <= n; j++) {
      for (int m = 0; m <= n; m++) {
        f[i][j][m] = 1e9;
      }
    }
  }
  for (int i = 1; i <= n; i++) c[i] = a[i] - k * b[i];
  f[1][0][1] = c[r[1]];
  for (int i = 2; i <= n; i++) {
    for (int j = 0; j <= n; j++) {
      for (int m = 0; m <= n; m++) {
        if (a[r[i]] == a[r[i - 1]]) {
          if (w[i] - m + i - w[i] - j <= j)
            f[i][j][m] = min(f[i][j][m], f[i - 1][j][m]);
          if (m > 0) f[i][j][m] = min(f[i][j][m], f[i - 1][j][m - 1] + c[r[i]]);
        } else {
          for (int q = min(j, w[i - 1]); q >= 0; q--) {
            f[i][j][1] = min(f[i][j][1], f[i - 1][j - q][q] + c[r[i]]);
            if (i - j <= j) f[i][j][0] = min(f[i][j][0], f[i - 1][j - q][q]);
          }
        }
        if (i == n && f[i][j][m] <= 0) {
          return true;
        }
      }
    }
  }
  return false;
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
  }
  for (int i = 1; i <= n; i++) {
    scanf("%d", &b[i]);
    r[i] = i;
  }
  sort(r + 1, r + 1 + n, cmp);
  w[1] = 1;
  for (int i = 2; i <= n; i++) {
    if (a[r[i - 1]] == a[r[i]])
      w[i] = w[i - 1] + 1;
    else
      w[i] = 1;
  }
  double lt = 0.009, rt = 100000000.0, mid;
  for (int cnt = 1; cnt <= 200; cnt++) {
    mid = (lt + rt) / 2;
    if (judge(mid))
      rt = mid;
    else
      lt = mid;
  }
  mid *= 1000;
  int ans = (mid - int(mid) <= 1e-7) ? (int)mid : (int)mid + 1;
  printf("%d\n", ans);
  return 0;
}
