#include #include #include #include int main(){ std::ios::sync_with_stdio(false); std::cin.tie(0); //input std::vector> len_black; int nw; std::cin >> nw; for(int i=0; i> w; len_black.push_back(std::make_pair(w, false)); } int nb; std::cin >> nb; for(int i=0; i> b; len_black.push_back(std::make_pair(b, true)); } //sort std::sort(len_black.begin(), len_black.end(), [](const auto& l, const auto& r){ return l.first>r.first; }); //solve int ans = -1; for(int color=0; color<2; ++color){ int tmpAns = 0; int readPos; int readLen; bool colorBlackF = (color==0) ? false : true; //search first block for(size_t i=0; i