#include <bits/stdc++.h>
using namespace std;
long long dp[55][55][55];
pair<long long, long long> power[55];
bool ok(long long threshold, int n) {
  for (int i = 0; i < 55; i++)
    for (int j = 0; j < 55; j++)
      for (int k = 0; k < 55; k++) dp[i][j][k] = 1000000000000000000LL;
  dp[0][0][0] = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < i + 1; j++) {
      for (int k = 0; k < i + 1; k++) {
        if (j + k > n) break;
        if (i == 0 || power[i].first != power[i - 1].first) {
          if (j + k > 0) {
            dp[i + 1][j + k - 1][0] = min(dp[i + 1][j + k - 1][0], dp[i][j][k]);
          }
          dp[i + 1][j + k][1] =
              min(dp[i + 1][j + k][1],
                  dp[i][j][k] + power[i].first - threshold * power[i].second);
        } else {
          if (j > 0) {
            dp[i + 1][j - 1][k] = min(dp[i + 1][j - 1][k], dp[i][j][k]);
          }
          dp[i + 1][j][k + 1] =
              min(dp[i + 1][j][k + 1],
                  dp[i][j][k] + power[i].first - threshold * power[i].second);
        }
      }
    }
  }
  long long minimum = dp[n][0][0];
  for (int j = 0; j < n + 1; j++)
    for (int k = 0; k < n + 1; k++) minimum = min(minimum, dp[n][j][k]);
  return (minimum <= 0);
}
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d", &power[i].first);
    power[i].first *= 1000;
  }
  for (int i = 0; i < n; i++) scanf("%d", &power[i].second);
  sort(power, power + n);
  reverse(power, power + n);
  long long hi = 100000000000LL, lo = 0LL;
  while (lo < hi) {
    long long mid = (lo + hi) / 2;
    if (ok(mid, n))
      hi = mid;
    else
      lo = mid + 1;
  }
  printf("%lld\n", hi);
}
