fork download
  1. #include <iostream>
  2. #include <algorithm>
  3.  
  4. int main () {
  5. std::vector<int> A = {1,2,2,3,3,5,6,6,12};
  6. std::vector<int> B = {1,2,2,4,5,5,7};
  7. std::vector<int> R;
  8. R.reserve(A.size()+B.size());
  9. std::merge(A.begin(), A.end(), B.begin(), B.end(), std::back_inserter(R));
  10. for(const auto &i:R) std::cout << i << " ";
  11. return 0;
  12. }
  13.  
Success #stdin #stdout 0s 3472KB
stdin
Standard input is empty
stdout
1 1 2 2 2 2 3 3 4 5 5 5 6 6 7 12