#include #include #include #include using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(0); int w; cin >> w; vector white(w); for (auto& i : white) { cin >> i; } sort(white.begin(), white.end()); int b; cin >> b; vector black(b); for (auto& i : black) { cin >> i; } sort(black.begin(), black.end()); int base_w = 1; int base_b = 1; int temp = -1; vector white2 = white; vector black2 = black; for (int i = (int)white.size() - 1; i >= 0; i--) { for (int j = (int)black.size() - 1; j >= 0; j--) { if (white.at(i) > black.at(j)) { temp = black.at(j); base_w++; break; } else { black.pop_back(); } } if (white.at(i) < temp) { temp = white.at(i); base_w++; } else { white.pop_back(); continue; } } for (int i = (int)black2.size() - 1; i >= 0; i--) { for (int j = (int)white2.size() - 1; j >= 0; j--) { if (black2.at(i) > white2.at(j)) { temp = white2.at(j); base_b++; break; } else { white2.pop_back(); } } if (black2.at(i) < temp) { temp = black2.at(i); base_b++; } else { black2.pop_back(); continue; } } cout << max(base_w, base_b) << endl; return 0; }