#include <bits/stdc++.h>
using namespace std;
int N;
int A[51], B[51];
double dp[52][52];
int ok(double a) {
  int i;
  vector<double> V;
  for (i = 0; i < (N); i++) V.push_back(A[i] - B[i] * a);
  sort((V.begin()), (V.end()));
  int x, y;
  for (x = 0; x < (52); x++)
    for (y = 0; y < (52); y++) dp[x][y] = 1e9;
  dp[0][0] = 0;
  double mi = 1e9;
  for (x = 0; x < (N); x++)
    for (y = 0; y < (N); y++) {
      int cur = 2 * x + y;
      if (cur >= N) {
        if (cur == N) mi = min(mi, dp[x][y]);
        break;
      }
      if (y) dp[x + 1][y - 1] = min(dp[x + 1][y - 1], dp[x][y]);
      dp[x][y + 1] = min(dp[x][y + 1], dp[x][y] + V[cur]);
    }
  return mi <= 0;
}
void solve() {
  int i, j, k, l, r, x, y;
  string s;
  cin >> N;
  for (i = 0; i < (N); i++) cin >> A[i];
  for (i = 0; i < (N); i++) cin >> B[i];
  double L = 0, R = 1e9;
  for (i = 0; i < (50); i++) {
    double M = (L + R) / 2;
    if (ok(M))
      R = M;
    else
      L = M;
  }
  cout << (signed long long)(1000 * L + 0.99) << endl;
}
int main(int argc, char** argv) {
  string s;
  int i;
  if (argc == 1) ios::sync_with_stdio(false), cin.tie(0);
  for (i = 0; i < (argc - 1); i++) s += argv[i + 1], s += '\n';
  for (i = 0; i < (s.size()); i++) ungetc(s[s.size() - 1 - i], stdin);
  cout.tie(0);
  solve();
  return 0;
}
