#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
const long long INFF = 0x3f3f3f3f3f3f3f3fll;
const long long M = 998244353;
const long long maxn = 1e5 + 7;
const double pi = acos(-1.0);
const double eps = 0.00000001;
long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
template <typename T>
inline T abs(T a) {
  return a > 0 ? a : -a;
}
template <typename T>
inline T powMM(T a, T b) {
  T ret = 1;
  for (; b; b >>= 1ll, a = (long long)a * a % M)
    if (b & 1) ret = (long long)ret * a % M;
  return ret;
}
long long f[57], g[57];
pair<long long, long long> A[57];
int n;
int check(long long x) {
  int l, r, i, k;
  l = r = 1;
  for (i = 1; i <= n; i++) g[i] = -INFF;
  g[0] = 0;
  long long all = 0;
  while (l <= n) {
    while (r <= n && A[r] == A[l]) r++;
    for (i = 1; i <= n; i++) f[i] = g[i];
    long long now = 0;
    for (k = 1; k <= r - l; k++) {
      now += A[k + l - 1].first - A[k + l - 1].second * x;
      for (i = 0; l - 1 - i - i >= k; i++) {
        g[i + k] = max(g[i + k], f[i] + now);
      }
    }
    all += now;
    l = r;
  }
  for (i = 0; i <= n / 2; i++)
    if (all - g[i] <= 0) return 1;
  return 0;
}
int TaskA() {
  int i, j, k;
  scanf("%d", &n);
  for (i = 1; i <= n; i++) scanf("%I64d", &A[i].first), A[i].first *= 1000;
  for (i = 1; i <= n; i++) scanf("%I64d", &A[i].second);
  sort(A + 1, A + n + 1);
  reverse(A + 1, A + 1 + n);
  long long l = 0, r = INF;
  while (l + 1 < r) {
    long long mid = (l + r) / 2;
    if (check(mid))
      r = mid;
    else
      l = mid;
  }
  printf("%I64d\n", r);
  return 0;
}
void initialize() {}
int main() {
  int startTime = clock();
  initialize();
  fprintf(stderr, "/--- initializeTime: %ld milliseconds ---/\n",
          clock() - startTime);
  int T = 1;
  startTime = clock();
  while (T--) TaskA();
  fprintf(stderr, "/--- computeTime: %ld milliseconds ---/\n",
          clock() - startTime);
}
