#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; using ll = long long; constexpr int INF = 1001001001; constexpr int mod = 1000000007; // constexpr int mod = 998244353; template inline bool chmax(T& x, T y){ if(x < y){ x = y; return true; } return false; } template inline bool chmin(T& x, T y){ if(x > y){ x = y; return true; } return false; } int main(){ ios::sync_with_stdio(false); cin.tie(nullptr); int N; cin >> N; vector A(N + 1), B(N + 1), D(N); 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]; D[i] *= -1; } sort(begin(D), end(D)); using node = pair; vector> dp(N + 1, vector(N + 1, {0, 0})); auto update = [](node& a, node b){ if(b.first > a.first) a = b; else if(b.first == a.first) chmin(a.second, b.second); }; for(int i = 0; i <= N; ++i){ for(int j = 0; j <= N; ++j){ auto& [cnt, pos] = dp[i][j]; if(i < N){ int score = A[i + 1] + B[j]; int npos = lower_bound(begin(D) + pos, end(D), -score) - begin(D); update(dp[i + 1][j], {cnt + (npos < N), min(npos + 1, N)}); } if(j < N){ int score = A[i] + B[j + 1]; int npos = lower_bound(begin(D) + pos, end(D), -score) - begin(D); update(dp[i][j + 1], {cnt + (npos < N), min(npos + 1, N)}); } } } int ans = 0; for(int i = 0; i <= N; ++i){ chmax(ans, dp[i][N - i].first); } cout << ans << endl; return 0; }