#include #include #include using namespace std; const int INF = 1 << 30; int getresult(vector W, vector B, bool wfirst) { int res = 0; int w_idx = (int)W.size() - 1; int b_idx = (int)B.size() - 1; // cout << w_idx << " " << b_idx << endl; int cur = INF; bool w_flag = wfirst; while (true) { // cout << (w_flag && w_idx < 0) << " " << (!w_flag && b_idx < 0) << endl; if (w_flag && w_idx < 0) break; if (!w_flag && b_idx < 0) break; if (w_flag) { if (W[w_idx] < cur) { cur = W[w_idx]; ++res; --w_idx; w_flag = !w_flag; // cout << "W " << res << " " << cur << " " << w_idx << " " << w_flag << endl; } else { --w_idx; } } else { if (B[b_idx] < cur) { cur = B[b_idx]; ++res; --b_idx; w_flag = !w_flag; // cout << "B " << res << " " << cur << " " << b_idx << " " << !w_flag << endl; } else { --b_idx; } } } return res; } int main() { int Nw, Nb; cin >> Nw; vector W(Nw); for (int i = 0; i < Nw; ++i) cin >> W[i]; cin >> Nb; vector B(Nb); for (int i = 0; i < Nb; ++i) cin >> B[i]; sort(W.begin(), W.end()); sort(B.begin(), B.end()); cout << max(getresult(W, B, true), getresult(W, B, false)) << endl; }