#include <bits/stdc++.h>
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
inline long long read() {
  register long long x = 0, f = 1;
  register char c = getchar();
  for (; !isdigit(c); c = getchar())
    if (c == '-') f = -1;
  for (; isdigit(c); c = getchar()) x = (x << 1) + (x << 3) + (c ^ 48);
  return x * f;
}
void write(long long x) {
  if (x < 0) x = -x, putchar('-');
  if (x >= 10) write(x / 10);
  putchar(x % 10 + '0');
}
void writeln(long long x) {
  write(x);
  puts("");
}
pair<long long, long long> a[55];
long long f[55][55];
long long sum[55];
int n;
bool check(long long mid) {
  memset(f, 0x3f, sizeof(f));
  f[0][0] = 0;
  for (int i = 1, j; i <= n; i = j) {
    for (j = i; a[j].first == a[i].first && j <= n; ++j)
      ;
    for (int k = i; k < j; ++k)
      sum[k - i + 1] = sum[k - i] + a[k].first - a[k].second * mid;
    for (register int k = (0); k <= int(n); ++k)
      for (int l = 0; l <= min(k, j - i); ++l)
        f[j - 1][(k - l) + (j - i) - l] = min(f[j - 1][(k - l) + (j - i) - l],
                                              f[i - 1][k] + sum[(j - i) - l]);
  }
  for (register int i = (0); i <= int(n); ++i)
    if (f[n][i] <= 0) return 1;
  return 0;
}
int main() {
  n = read();
  for (register int i = (1); i <= int(n); ++i) a[i].first = read() * 1000;
  for (register int i = (1); i <= int(n); ++i) a[i].second = read();
  sort(a + 1, a + 1 + n, greater<pair<long long, long long> >());
  long long l = 1, r = 1e13, ans;
  while (l <= r) {
    long long mid = (l + r) >> 1;
    if (check(mid))
      ans = mid, r = mid - 1;
    else
      l = mid + 1;
  }
  writeln(ans);
  return 0;
}
