#include #include #include #include using namespace std; using namespace atcoder; using namespace __gnu_pbds; using ll=long long; using ld=long double; using vll=vector; using vvll=vector; using pll=pair; // using mint=modint; // template // using ordered_map=tree,rb_tree_tag,tree_order_statistics_node_update>; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); ll Nw,Nb; cin>>Nw; vll W(Nw); for(int i=0;i>W[i]; cin>>Nb; vll B(Nb); for(int i=0;i>B[i]; sort(W.rbegin(),W.rend()); sort(B.rbegin(),B.rend()); auto solve=[&](bool white){ ll wi=0,bi=0; ll last=LLONG_MAX; ll h=0; while(1){ if(white){ while(wi=last)wi++; if(wi==Nw)break; last=W[wi]; wi++; h++; }else{ while(bi=last)bi++; if(bi==Nb)break; last=B[bi]; bi++; h++; } white^=1; } return h; }; cout<