#include #include #include using namespace std; bool choose_block(int &top, vector &b) { while (!b.empty() && b.back() >= top) { b.pop_back(); } if (b.empty()) { return false; } top = b.back(); b.pop_back(); return true; } int simulate(vector b1, vector b2) { int ans = 0; int top = 1 << 30; for (;;) { if (!choose_block(top, b1)) { break; } ++ans; if (!choose_block(top, b2)) { break; } ++ans; } return ans; } int main() { int Nw; cin >> Nw; vector W(Nw); for (auto &x : W) { cin >> x; } int Nb; cin >> Nb; vector B(Nb); for (auto &x : B) { cin >> x; } sort(begin(W), end(W)); sort(begin(B), end(B)); int ans = max(simulate(W, B), simulate(B, W)); cout << ans << endl; }