fork download
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. int x,y,a[100009],b[100009],n,m;
  6.  
  7. int main(){
  8. cin>>n>>m;
  9. for(int i=0;i<n;i++){
  10. cin>>a[i];
  11. }
  12. for(int i=0;i<m;i++){
  13. cin>>b[i];
  14. }
  15. x=0; y=0;
  16. while(x<n && y<m ){
  17. if(a[x]>b[y] ){
  18. cout<<b[y]<<" ";
  19. y++;
  20. }
  21. else if(a[x]<= b[y] ){
  22. cout<<a[x]<<" ";
  23. x++;
  24. }
  25. }
  26. while(x<n){
  27. cout<<a[x]<<" ";
  28. x++;
  29. }
  30. while(y<m){
  31. cout<<b[y]<<" ";
  32. y++;
  33. }
  34. }
  35.  
Success #stdin #stdout 0.01s 5288KB
stdin
Standard input is empty
stdout
Standard output is empty