#include <bits/stdc++.h>
const int N = 55;
const double inf = 1e17;
using namespace std;
int n;
struct node {
  int h, w;
  double val;
  bool friend operator<(node a, node b) {
    return a.h > b.h || (a.h == b.h && a.val < b.val);
  }
} a[N];
double f[N][N];
void upd(double &x, double y) {
  if (y < x) x = y;
}
bool Chk(double x) {
  f[0][0] = 0;
  for (int i = 1; i <= n; ++i) {
    a[i].val = a[i].h - x * a[i].w;
  }
  sort(a + 1, a + n + 1);
  for (int i = 1, j; i <= n; i = j) {
    for (j = i + 1; j <= n && a[i].h == a[j].h; ++j)
      ;
    double SumVal = 0;
    for (int k = 0; k <= n; ++k) f[j - 1][k] = inf;
    for (int k = 0; k <= j - i; ++k) {
      if (k) SumVal += a[i + k - 1].val;
      for (int p = j - i - k; p <= i - 1; ++p)
        upd(f[j - 1][p - j + i + k * 2], f[i - 1][p] + SumVal);
    }
  }
  for (int k = 0; k <= n; ++k)
    if (f[n][k] < 0) return true;
  return false;
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) scanf("%d", &a[i].h);
  for (int i = 1; i <= n; ++i) scanf("%d", &a[i].w);
  double l = 0, r = 0;
  for (int i = 1; i <= n; ++i) r += a[i].h;
  for (int t = 1; t <= 60; ++t) {
    double mid = (l + r) / 2;
    if (Chk(mid))
      r = mid;
    else
      l = mid;
  }
  printf("%.f\n", ceil(l * 1000));
  return 0;
}
