#include <bits/stdc++.h>
using namespace std;
const int N = 55;
pair<long long, long long> p[N];
long long f[N][N], sum[N];
int n;
bool check(long long mid) {
  memset(f, 60, sizeof(f));
  f[0][0] = 0;
  for (int i = 1, j = 1; i <= n; i = j) {
    while (p[j].first == p[i].first && j <= n) j++;
    for (int k = i; k < j; k++)
      sum[k - i + 1] = sum[k - i] + p[k].first - p[k].second * mid;
    for (int k = 0; k <= 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 (int i = 0; i <= n; i++)
    if (f[n][i] <= 0) return 1;
  return 0;
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%lld", &p[i].first), p[i].first *= 1000;
  }
  for (int i = 1; i <= n; i++) scanf("%lld", &p[i].second);
  sort(p + 1, p + n + 1);
  reverse(p + 1, p + n + 1);
  long long l = 1, r = 1000000000000;
  while (l < r) {
    long long mid = (l + r) / 2;
    if (check(mid))
      r = mid;
    else
      l = mid + 1;
  }
  printf("%lld\n", l);
}
