#include <bits/stdc++.h>
using namespace std;
const long long INF = (long long)1e18;
const long long C = (long long)1e14;
const int N = 55;
int n;
long long a[N][2];
pair<long long, long long> b[N];
long long dp[N][N];
bool solve(long long X) {
  for (int i = 0; i < n; i++) b[i] = make_pair(a[i][0], a[i][0] - a[i][1] * X);
  sort(b, b + n);
  reverse(b, b + n);
  for (int i = 0; i <= n; i++)
    for (int j = 0; j <= n; j++) dp[i][j] = INF;
  dp[0][0] = 0;
  int L = 0;
  while (L < n) {
    int R = L;
    while (R < n && b[L].first == b[R].first) R++;
    for (int was = 0; was <= L; was++) {
      if (dp[L][was] == INF) continue;
      long long sum = dp[L][was];
      for (int i = L; i < R; i++) sum += b[i].second;
      for (int cnt = 0; cnt <= R - L; cnt++) {
        if (cnt <= was)
          dp[R][was - cnt + R - L - cnt] =
              min(dp[R][was - cnt + R - L - cnt], sum);
        sum -= b[L + cnt].second;
      }
    }
    L = R;
  }
  for (int i = 0; i <= n; i++)
    if (dp[n][i] <= 0) return true;
  return false;
}
int main() {
  scanf("%d", &n);
  for (int i = 0; i < 2; i++)
    for (int j = 0; j < n; j++) scanf("%lld", &a[j][i]);
  for (int i = 0; i < n; i++) a[i][0] *= 1000;
  long long L = 0, R = C;
  while (R - L > 1) {
    long long x = (L + R) / 2;
    if (solve(x))
      R = x;
    else
      L = x;
  }
  printf("%lld\n", R);
  return 0;
}
