#include <bits/stdc++.h>
using namespace std;
const int MAX_N = 50;
const int CNT = 200;
const double DINF = 1e60;
const double DELTA = 1e-6;
int as[MAX_N], bs[MAX_N];
pair<int, int> ps[MAX_N];
double qs[MAX_N], dp[MAX_N + 1][MAX_N + 1][MAX_N + 1];
inline void setmin(double &a, double b) {
  if (a > b) a = b;
}
bool check(int n, double av) {
  for (int i = 0; i < n; i++) qs[i] = ps[i].first - av * ps[i].second;
  for (int i = 0; i <= n; i++)
    for (int j = 0; j <= n; j++) fill(dp[i][j], dp[i][j] + n + 1, DINF);
  dp[0][0][0] = 0.0;
  for (int i = 0; i < n; i++)
    for (int j = 0; j <= i; j++)
      for (int k = 0; k <= i; k++)
        if (dp[i][j][k] < DINF) {
          int j1 = j, k1 = k;
          if (i > 0 && ps[i - 1].first != ps[i].first) j1 += k1, k1 = 0;
          if (j1 > 0) setmin(dp[i + 1][j1 - 1][k1], dp[i][j][k]);
          setmin(dp[i + 1][j1][k1 + 1], dp[i][j][k] + qs[i]);
        }
  double mind = DINF;
  for (int j = 0; j <= n; j++)
    for (int k = 0; k <= n; k++) setmin(mind, dp[n][j][k]);
  return (mind > 0.0);
}
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) scanf("%d", as + i);
  for (int i = 0; i < n; i++) scanf("%d", bs + i);
  int maxa = 0;
  for (int i = 0; i < n; i++) {
    ps[i] = pair<int, int>(as[i], bs[i]);
    if (maxa < as[i]) maxa = as[i];
  }
  sort(ps, ps + n, greater<pair<int, int> >());
  double v0 = 0.0, v1 = maxa;
  for (int cnt = 0; cnt < CNT; cnt++) {
    double v = (v0 + v1) / 2;
    if (check(n, v))
      v0 = v;
    else
      v1 = v;
  }
  printf("%lld\n", llround(v1 * 1000 + DELTA));
  return 0;
}
