#include <bits/stdc++.h>
using namespace std;
template <class T>
inline void amin(T &x, const T &y) {
  if (y < x) x = y;
}
template <class T>
inline void amax(T &x, const T &y) {
  if (x < y) x = y;
}
template <class Iter>
void rprintf(const char *fmt, Iter begin, Iter end) {
  for (bool sp = 0; begin != end; ++begin) {
    if (sp)
      putchar(' ');
    else
      sp = true;
    printf(fmt, *begin);
  }
  putchar('\n');
}
int N;
pair<long long, long long> P[55];
long long buf_[2][55];
long long *cur = buf_[0];
long long *nxt = buf_[1];
long long sums[55];
const int BASE = 1000;
bool ok(long long W) {
  memset(cur, 0x3f, sizeof buf_[0]);
  cur[0] = 0;
  for (int i = 0; i < N;) {
    memset(nxt, 0x3f, sizeof buf_[0]);
    int j = i;
    int len = 0;
    while (j < N && P[i].first == P[j].first) {
      sums[len + 1] = sums[len] + BASE * P[j].first - W * P[j].second;
      len++;
      j++;
    }
    for (int k = 0, k_len = (i + 1); k < k_len; ++k) {
      for (int b = 0, b_len = (min(k + 1, len + 1)); b < b_len; ++b) {
        int a = len - b;
        amin(nxt[k + a - b], cur[k] + sums[a]);
      }
    }
    swap(cur, nxt);
    i = j;
  }
  return *min_element(cur, cur + N + 1) <= 0;
}
void MAIN() {
  scanf("%d", &N);
  for (int i = 0, i_len = (N); i < i_len; ++i) scanf("%lld", &P[i].first);
  for (int i = 0, i_len = (N); i < i_len; ++i) scanf("%lld", &P[i].second);
  sort(P, P + N);
  reverse(P, P + N);
  long long lo = 0, hi = 1;
  while (!ok(hi)) {
    lo = hi;
    hi += hi;
  }
  while (hi - lo > 1) {
    long long mid = (lo + hi) / 2;
    (ok(mid) ? hi : lo) = mid;
  }
  printf("%lld\n", hi);
}
int main() {
  int TC = 1;
  for (int tc = 0, tc_len = (TC); tc < tc_len; ++tc) MAIN();
  return 0;
}
