#include <bits/stdc++.h>
using namespace std;
const int N = 50 + 5;
const double ex = 1e-5;
struct node {
  double a, b;
} q[N];
struct data {
  double c, a;
} s[N];
int n;
double ans;
double f[N][N], sum[N];
bool cmp(data a, data b) { return a.a == b.a ? a.c > b.c : a.a > b.a; }
bool check(double x) {
  double ret = 1e10;
  for (int i = 1; i <= n; ++i) s[i] = (data){q[i].a - x * q[i].b, q[i].a};
  sort(s + 1, s + n + 1, cmp);
  for (int i = 1; i <= n; ++i) sum[i] = sum[i - 1] + s[i].c;
  memset(f, 0x7f, sizeof(f));
  f[0][0] = 0;
  int l = 1, r = 1, tot = 0;
  while (l <= n) {
    r = l, ++tot;
    while (r < n && s[r].a == s[r + 1].a) ++r;
    for (int i = 0; i < l; ++i)
      for (int j = l - 1; j <= r; ++j)
        if (j - l + 1 <= i)
          f[tot][i - (j - l + 1) + r - j] = min(
              f[tot][i - (j - l + 1) + r - j], f[tot - 1][i] + sum[r] - sum[j]);
    l = r + 1;
  }
  for (int i = 0; i <= n; ++i) ret = min(ret, f[tot][i]);
  return ret <= 0;
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) scanf("%lf", &q[i].a);
  for (int i = 1; i <= n; ++i) scanf("%lf", &q[i].b);
  double l = 0.0, r = 1e8;
  while ((r - l) >= ex) {
    double mid = (l + r) / 2;
    if (check(mid))
      r = mid;
    else
      l = mid;
  }
  printf("%I64d\n", (long long)ceil(l * 1000));
  return 0;
}
