#include #define all(vec) vec.begin(), vec.end() using namespace std; using ll = long long; using P = pair; constexpr ll INF = (1LL << 30) - 1LL; constexpr ll LINF = (1LL << 60) - 1LL; constexpr ll MOD = 1e9 + 7; template void chmin(T &a, T b) { a = min(a, b); } template void chmax(T &a, T b) { a = max(a, b); } int main() { cin.tie(0); ios::sync_with_stdio(false); int n; cin >> n; vector a(n), b(n), d(n), i1(n + 1), i2(n + 1); for (int i = 0; i <= n; i++) { cin >> a[i]; } for (int i = 0; i <= n; i++) { cin >> b[i]; } for (int i = 0; i < n; i++) { cin >> d[i]; } sort(all(d)); reverse(all(d)); for (int i = 1; i <= n; i++) { if (a[i1[i - 1]] - a[i1[i - 1] + 1] < b[i2[i - 1]] - b[i2[i - 1] + 1]) { i1[i] = i1[i - 1] + 1; i2[i] = i2[i - 1]; } else { i2[i] = i2[i - 1] + 1; i1[i] = i1[i - 1]; } // cout << i1[i] << " " << i2[i] << endl; } vector> dp(n + 1, vector(n + 1)); dp[0][0] = 1; for (int i = 0; i < n; i++) { for (int j = 0; j <= n; j++) { dp[i + 1][j] |= dp[i][j]; if (j > 0) { if (a[i1[j]] + b[i2[j]] >= d[i]) { dp[i + 1][j] |= dp[i][j - 1]; } } } } int res = 0; for (int i = 0; i <= n; i++) { if (dp[n][i]) { chmax(res, i); } } cout << res << endl; }