#include <bits/stdc++.h>
using namespace std;
inline int ty() {
  register int a = 0, b = 1, c = getchar();
  while (!isdigit(c)) b ^= c == '-', c = getchar();
  while (isdigit(c)) a = a * 10 + c - 48, c = getchar();
  return b ? a : -a;
}
const int _ = 53;
const double eps = 1e-6;
int n, cp[_], tp[_];
double val[_], f[_][_], sf[_];
double finder() {
  register int i, j, k, a, b;
  register double ans = 1e99;
  memset(f, 70, sizeof(f)), memset(sf, 0, sizeof(sf)), f[0][0] = 0;
  for (i = 1, j = 1; i <= n; i = j + 1) {
    j = i;
    while (j < n && cp[j + 1] == cp[i]) j++;
    for (k = i; k <= j; k++) sf[k - i + 1] = sf[k - i] + val[k];
    for (k = 0; k <= n; k++)
      for (a = 0; a <= min(k, j - i + 1); a++) {
        b = (k - a) + (j - i + 1) - a;
        f[j][b] = min(f[j][b], f[i - 1][k] + sf[(j - i + 1) - a]);
      }
  }
  for (i = 0; i <= n; i++) ans = min(ans, f[n][i]);
  return ans;
}
int check(double tar) {
  register int i;
  for (i = 1; i <= n; i++) val[i] = cp[i] - tar * tp[i];
  return finder() <= 0;
}
inline int cmp(pair<int, int> a, pair<int, int> b) {
  if (a.first == b.first) return a.second > b.second;
  return a.first > b.first;
}
pair<int, int> temp[_];
int main() {
  register int i;
  register double l, r, mid;
  n = ty();
  for (i = 1; i <= n; i++) temp[i].first = ty();
  for (i = 1; i <= n; i++) temp[i].second = ty();
  sort(temp + 1, temp + n + 1, cmp);
  for (i = 1; i <= n; i++) cp[i] = temp[i].first, tp[i] = temp[i].second;
  l = 0, r = 1e8 + 1;
  while (abs(r - l) >= eps) {
    mid = (l + r) / 2;
    if (check(mid))
      r = mid;
    else
      l = mid;
  }
  printf("%I64d\n", (long long)(l * 1000 + 1 - eps));
  return 0;
}
