#include <bits/stdc++.h>
using namespace std;
const int N = 55;
long long n, dp[N][N], sum[N];
pair<pair<long long, long long>, long long> a[N];
bool cmp(pair<pair<long long, long long>, long long> a,
         pair<pair<long long, long long>, long long> b) {
  return a > b;
}
bool check(long long val) {
  for (int i = 1; i <= n; i++) {
    a[i].first.second = a[i].first.first - val * a[i].second;
  }
  sort(a + 1, a + 1 + n, cmp);
  for (int i = 0; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
      dp[i][j] = -1e18;
    }
  }
  int pre = 0;
  for (int i = 1; i <= n; i++) {
    sum[i] = sum[i - 1] + a[i].first.second;
    if (a[i].first.first == a[i + 1].first.first) continue;
    for (int j = 1; j * 2 <= i; j++) {
      for (int k = 0; k <= min(j, i - pre); k++) {
        if (pre - 2 * (j - k) >= k) {
          dp[i][j] = max(dp[i][j], dp[pre][j - k] + sum[pre + k] - sum[pre]);
        }
      }
    }
    pre = i;
  }
  long long mx = 0;
  for (int i = 0; i <= n; i++) {
    mx = max(mx, dp[n][i]);
  }
  return (sum[n] - mx) <= 0;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i].first.first;
    a[i].first.first *= 1000;
  }
  for (int i = 1; i <= n; i++) cin >> a[i].second;
  long long L = 0, R = 1e12;
  while (L < R) {
    long long mid = (L + R) >> 1;
    if (check(mid)) {
      R = mid;
    } else {
      L = mid + 1;
    }
  }
  cout << L;
}
