#include <bits/stdc++.h>
inline long long read() {
  char c = getchar();
  while (c != '-' && (c < '0' || c > '9')) c = getchar();
  long long k = 0, kk = 1;
  if (c == '-') c = getchar(), kk = -1;
  while (c >= '0' && c <= '9') k = k * 10 + c - '0', c = getchar();
  return k * kk;
}
void write(long long x) {
  if (x < 0) putchar('-'), x = -x;
  if (x / 10) write(x / 10);
  putchar(x % 10 + '0');
}
void writeln(long long x) {
  write(x);
  puts("");
}
using namespace std;
long long n, a[1010], b[1010], ff[1010], gg[1010], qvq[1010];
struct lsg {
  long long x, y;
} f[1010];
bool cmp(lsg x, lsg y) { return x.y < y.y || x.y == y.y && x.x < y.x; }
bool pd(long long x) {
  for (long long i = 1; i <= n; i++) f[i].x = a[i] - b[i] * x, f[i].y = a[i];
  sort(f + 1, f + 1 + n, cmp);
  memset(ff, 0, sizeof(ff));
  for (long long i = 1; i <= n; i++) {
    memset(gg, 100, sizeof(gg));
    long long j = i;
    qvq[j - i + 1] = f[i].x;
    while (f[j + 1].y == f[i].y && j <= n)
      j++, qvq[j - i + 1] = qvq[j - i] + f[j].x;
    for (long long k = 0; k <= j - i + 1; k++)
      for (long long l = k; l <= n; l++)
        gg[l] = min(gg[l], ff[l - k * 2 + (j - i + 1)] + qvq[(j - i + 1) - k]);
    for (long long k = 0; k <= n; k++) ff[k] = gg[k];
    i = j;
  }
  return ff[0] <= 0;
}
signed main() {
  n = read();
  for (long long i = 1; i <= n; i++) a[i] = read() * 10000;
  for (long long i = 1; i <= n; i++) b[i] = read();
  long long l = 0, r = 1e15;
  while (l < r) {
    long long m = (l + r) >> 1;
    if (pd(m))
      r = m;
    else
      l = m + 1;
  }
  writeln((l + 9) / 10);
}
