#include <bits/stdc++.h>
using namespace std;
#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back
#define x first
#define y second
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define RFOR(i, a, b) for(int i = (a) - 1; i >= (b); i--)
typedef long long ll;
typedef double db;
typedef long double LD;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<db, db> pdd;
int solve()
{
int n;
if (!(cin >> n))
return 1;
vector<pll> p(n);
FOR (i, 0, n)
cin >> p[i].x;
FOR (i, 0, n)
cin >> p[i].y;
vector<ll> m(n), pp(n);
FOR (i, 0, n)
m[i] = p[i].x;
FOR (i, 0, n)
pp[i] = p[i].y;
sort(all(p), [&](pll l, pll r)
{
return l.x-l.y > r.x - r.y;
});
ll ans = 0;
ll res = 0;
ll l1 = 0, r1 = 0;
FOR(i,0,n/2)
{
l1 +=p[i].x;
r1+= p[n-i-1].y;
if(l1 >= r1)
ans = i+1;
}
cerr << ans << endl;
res = max(res,ans);
sort(rall(p), [&](pll l, pll r)
{
return l.x-l.y > r.x - r.y;
});
ll ans = 0;
ll res = 0;
ll l1 = 0, r1 = 0;
FOR(i,0,n/2)
{
l1 +=p[i].x;
r1+= p[n-i-1].y;
if(l1 >= r1)
ans = i+1;
}
cerr << ans << endl;
res = max(res,ans);
sort(all(p), [&](pll l, pll r)
{
return l.x+l.y > r.x + r.y;
});
ans = 0;
l1 = 0, r1 = 0;
FOR(i,0,n/2)
{
l1 +=p[i].x;
r1+= p[n-i-1].y;
if(l1 >= r1)
ans = i+1;
}
cerr << ans << endl;
res = max(res,ans);
sort(rall(p), [&](pll l, pll r)
{
return l.x+l.y > r.x + r.y;
});
ans = 0;
l1 = 0, r1 = 0;
FOR(i,0,n/2)
{
l1 +=p[i].x;
r1+= p[n-i-1].y;
if(l1 >= r1)
ans = i+1;
}
cerr << ans << endl;
res = max(res,ans);
sort(all(p), [&](pll l, pll r)
{
return l.x*l.y > r.x*r.y;
});
ans = 0;
l1 = 0, r1 = 0;
FOR(i,0,n/2)
{
l1 +=p[i].x;
r1+= p[n-i-1].y;
if(l1 >= r1)
ans = i+1;
}
cerr << ans << endl;
res = max(res,ans);
sort(rall(p), [&](pll l, pll r)
{
return l.x*l.y > r.x*r.y;
});
ans = 0;
l1 = 0, r1 = 0;
FOR(i,0,n/2)
{
l1 +=p[i].x;
r1+= p[n-i-1].y;
if(l1 >= r1)
ans = i+1;
}
cerr << ans << endl;
res = max(res,ans);
sort(rall(p), [&](pll l, pll r)
{
return l.x*r.y > r.x*l.y;
});
ans = 0;
l1 = 0, r1 = 0;
FOR(i,0,n/2)
{
l1 +=p[i].x;
r1+= p[n-i-1].y;
if(l1 >= r1)
ans = i+1;
}
cerr << ans << endl;
res = max(res,ans);
sort(rall(p), [&](pll l, pll r)
{
return abs(l.x-l.y) > abs(r.x-r.y);
});
ans = 0;
l1 = 0, r1 = 0;
FOR(i,0,n/2)
{
l1 +=p[i].x;
r1+= p[n-i-1].y;
if(l1 >= r1)
ans = i+1;
}
cerr << ans << endl;
res = max(res,ans);
sort(rall(p), [&](pll l, pll r)
{
return l.x > l.y;
});
ans = 0;
l1 = 0, r1 = 0;
FOR(i,0,n/2)
{
l1 +=p[i].x;
r1+= p[n-i-1].y;
if(l1 >= r1)
ans = i+1;
}
cerr << ans << endl;
res = max(res,ans);
vector<bool> del(n);
vector<int> ord1(n), ord2(n);
iota(all(ord1), 0);
iota(all(ord2), 0);
sort(all(ord1), [&](int l, int r)
{
return m[l] > m[r];
});
sort(all(ord2), [&](int l, int r)
{
return pp[l] < pp[r];
});
int it1 = 0, it2 = 0;
vector<pii> pr;
FOR (i, 0, n / 2)
{
while (del[ord1[it1]])
it1++;
while (del[ord2[it2]])
it2++;
int i1 = ord1[it1];
int i2 = ord2[it2];
if (i1 != i2)
{
pr.pb(pii{i1, i2});
del[i1] = 1;
del[i2] = 1;
while (del[ord1[it1]])
it1++;
while (del[ord2[it2]])
it2++;
continue;
}
int it12 = it1 + 1;
while (del[ord1[it12]])
it12++;
int it22 = it2 + 1;
while (del[ord2[it22]])
it22++;
int i12 = ord1[it12];
int i22 = ord2[it22];
if (m[i1] - pp[i22] > m[i12] - pp[i2])
{
pr.pb({i1, i22});
del[i1] = 1;
del[i22] = 1;
}
else
{
pr.pb({i12, i2});
del[i12] = 1;
del[i2] = 1;
}
}
ans = 0;
ll bal = 0;
FOR (i, 0, n / 2)
{
int l = pr[i].x, r = pr[i].y;
cerr << "l = " << l << " r = " << r << '\n';
bal += m[l] - pp[r];
if (bal < 0)
{
bal -= m[l] - pp[r];
continue;
}
ans++;
}
res = max(res, ans);
cout << res << endl;
return 0;
}
int32_t main()
{
ios::sync_with_stdio(0);
cin.tie(0);
int TET = 1e9;
//cin >> TET;
for (int i = 1; i <= TET; i++)
{
if (solve())
{
break;
}
#ifdef ONPC
cerr << "_________________________\n";
#endif
}
#ifdef ONPC
cerr << "\nfinished in " << clock() * 1.0 / CLOCKS_PER_SEC << " sec\n";
#endif
return 0;
}