#include <bits/stdc++.h>
using namespace std;
int n;
double DP[200][200][200];
pair<long long int, long long int> arr[100];
double val[100];
bool visited[200][200][200];
void update(int a, int b, int c, double val) {
  if (visited[a][b][c]) {
    DP[a][b][c] = min(DP[a][b][c], val);
  } else {
    visited[a][b][c] = true;
    DP[a][b][c] = val;
  }
}
bool test(double d) {
  for (int i = 0; i < n; i++)
    val[i] = (double)arr[i].first - (double)arr[i].second * d;
  for (int i = 0; i < n + 1; i++) {
    for (int j = 0; j < n + 1; j++) {
      for (int k = 0; k < n + 1; k++) visited[i][j][k] = false;
    }
  }
  DP[0][0][0] = 0;
  visited[0][0][0] = true;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n + 1; j++) {
      for (int k = 0; k < n + 1; k++) {
        if (visited[i][j][k]) {
          if (i == 0 || arr[i].first < arr[i - 1].first) {
            update(i + 1, j + 1, 1, DP[i][j][k] + val[i]);
            if (j > 0) update(i + 1, j - 1, 0, DP[i][j][k]);
          } else {
            update(i + 1, j + 1, k + 1, DP[i][j][k] + val[i]);
            if (j > 0 && j > k) update(i + 1, j - 1, k, DP[i][j][k]);
          }
        }
      }
    }
  }
  for (int i = 0; i < n + 1; i++) {
    for (int j = 0; j < n + 1; j++) {
      if (visited[n][i][j]) {
        if (DP[n][i][j] <= 0) return true;
      }
    }
  }
  return false;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n;
  for (int i = 0; i < n; i++) cin >> arr[i].first;
  for (int i = 0; i < n; i++) cin >> arr[i].second;
  sort(arr, arr + n);
  reverse(arr, arr + n);
  double lo = 0;
  double hi = 1E12;
  for (int t = 0; t < 60; t++) {
    double mid = (hi + lo) / 2;
    if (test(mid))
      hi = mid;
    else
      lo = mid;
  }
  hi *= 1000;
  cout << (long long int)hi << endl;
  return 0;
}
