#include <bits/stdc++.h>
#pragma GCC optimize(3)
using namespace std;
int n, k, a[55], b[55];
double dp[55][55][55];
pair<int, double> v[55];
void Max(double *x, double y) { *x = max(*x, y); }
bool cmp(pair<int, double> p, pair<int, double> q) {
  if (p.first != q.first) return p.first > q.first;
  return p.second > q.second;
}
bool C(double x) {
  for (int i = 1; i <= n; i++) v[i] = pair<int, double>(a[i], x * b[i] - a[i]);
  sort(v + 1, v + n + 1, cmp);
  for (int i = 0; i <= n; i++)
    for (int j = 0; j <= n; j++)
      for (int k = 0; k <= n; k++) dp[i][j][k] = -1000000000;
  dp[0][0][0] = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j <= i; j++)
      for (int k = 0; j + k <= i; k++) {
        if (dp[i][j][k] == -1000000000) continue;
        if (i == 0 || v[i].first != v[i + 1].first) {
          Max(&dp[i + 1][j + k][1], dp[i][j][k] + v[i + 1].second);
          if (j + k > 0) Max(&dp[i + 1][j + k - 1][0], dp[i][j][k]);
        } else {
          Max(&dp[i + 1][j][k + 1], dp[i][j][k] + v[i + 1].second);
          if (j != 0) Max(&dp[i + 1][j - 1][k], dp[i][j][k]);
        }
      }
  }
  for (int i = 0; i <= n; i++)
    for (int j = 0; i + j <= n; j++)
      if (dp[n][i][j] >= 0) return true;
  return false;
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  for (int i = 1; i <= n; i++) scanf("%d", &b[i]);
  double l = 0, r = 2e9;
  for (int i = 0; i < 200; i++) {
    double mid = (l + r) / 2;
    if (C(mid))
      r = mid;
    else
      l = mid;
  }
  printf("%lld\n", (long long)(r * 1000 + 0.999));
  return 0;
}
