#include "omp.h"
#include <iostream>
#include <iomanip>
#include <string>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <vector>
#include <cassert>
#include <fstream>
#include <algorithm>
#include <list>
#include <random>
#include <ctime>
#include <random>
#include <bitset>
#include <unordered_set>
#include <cassert>
#include <list>


using namespace std;

typedef long long ll;
typedef long double ld;


const int sze = 50, M = 5e3 + 1, psze = 15;
const pair<ll, ll> INF = { 6e12, 1 };


pair<ll, ll> dp[2][sze][sze];


void update(pair<ll, ll> &cur, pair<ll, ll> prev, pair<ll, ll> add)
{
	if (ld(cur.first) / cur.second > ld(prev.first + add.first) / (prev.second + add.second))
		cur = { prev.first + add.first, prev.second + add.second };

}


void mmax(pair<ll, ll> &cur, pair<ll, ll> prev)
{
	if (ld(cur.first) / cur.second > ld(prev.first) / prev.second)
		cur = prev;
}


signed main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);

	for (int i = 0; i < sze; ++i)
		for (int z = 0; z < sze; ++z)
			for (int cur = 0; cur <= 1; ++cur)
				dp[cur][i][z] = INF;

	int n;
	cin >> n;
	vector<pair<ll, ll>> challengers(n);

	for (int i = 0; i < n; ++i)
		cin >> challengers[i].first;

	for (int i = 0; i < n; ++i)
		cin >> challengers[i].second;

	sort(challengers.begin(), challengers.end());

	int cur = 0;
	for (int t = 0; t < n; ++t)
	{

		for (int i = 0; i < sze; ++i)
			for (int z = 0; z < sze; ++z)
			{
				if (dp[cur][i][z] == INF)
					continue;

				update(dp[cur ^ 1][t][max(0, z + t - i - 2)], dp[cur][i][z], challengers[t]);
			}

		mmax(dp[cur ^ 1][t][max(0, t - 1)], challengers[t]);

		for (int i = 0; i < sze; ++i)
			for (int z = 0; z < sze; ++z)
			{
				mmax(dp[cur ^ 1][i][z + 1], dp[cur][i][z]);
				dp[cur][i][z] = INF;
			}
		cur ^= 1;
	}

	ld ans = INF.first;

	for (int cur = 0; cur <= 1; ++cur)
		if (dp[cur][n - 1][0] != INF)
			ans = min(ans, ceil(ld(1000) * dp[cur][n - 1][0].first / dp[cur][n - 1][0].second));

	cout << fixed << setprecision(0) << ans;

	return 0;
}