#include <bits/stdc++.h>
using namespace std;
long long dp[55][55][5050], s[55];
vector<int> vi;
pair<int, int> p[55];
double res = 1e16;
int n;
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", &p[i].first);
  for (int i = 1; i <= n; i++) scanf("%d", &p[i].second);
  sort(p + 1, p + 1 + n, [](pair<int, int> x, pair<int, int> y) {
    return x.first > y.first || (x.first == y.first && x.second < y.second);
  });
  for (int i = 1; i <= n; i++) s[i] = s[i - 1] + p[i].second;
  vi.push_back(0);
  for (int i = 1; i < n; i++)
    if (p[i].first != p[i + 1].first) vi.push_back(i);
  vi.push_back(n);
  fill(&dp[0][0][0], &dp[54][54][5050], long long(1e15));
  dp[0][0][0] = 0;
  for (int i = 1; i < vi.size(); i++) {
    for (int j = 0; j <= vi[i - 1]; j++) {
      for (int k = 0; k <= vi[i] - vi[i - 1]; k++)
        if (j >= k) {
          int j2 = j + vi[i] - vi[i - 1] - k - k;
          int a = s[vi[i]] - s[vi[i - 1] + k];
          long long b = 1LL * (vi[i] - vi[i - 1] - k) * p[vi[i]].first;
          for (int l = a; l <= 5000; l++)
            dp[i][j2][l] = min(dp[i][j2][l], dp[i - 1][j][l - a] + b);
        }
    }
  }
  for (int i = 0; i <= n; i++)
    for (int j = 1; j <= 5000; j++)
      res = min(res, 1.0 * dp[vi.size() - 1][i][j] / j);
  printf("%.0lf", res * 1000);
  return 0;
}
