fork download
  1. using System;
  2. using System.IO;
  3. using System.Text;
  4.  
  5. namespace 콘솔테스트
  6. {
  7. class Program
  8. {
  9. static void Main(string[] args)
  10. {
  11. StreamReader sr = new StreamReader(Console.OpenStandardInput());
  12. StringBuilder sb = new StringBuilder();
  13.  
  14. string[] index = sr.ReadLine().Split(' ');
  15. int n = int.Parse(index[0]);
  16. int m = int.Parse(index[1]);
  17.  
  18. int[] a = Array.ConvertAll(sr.ReadLine().Split(new char[] { ' ' }, StringSplitOptions.None), s => int.Parse(s));
  19. int[] b = Array.ConvertAll(sr.ReadLine().Split(new char[] { ' ' }, StringSplitOptions.None), s => int.Parse(s));
  20.  
  21. int a_index = 0;
  22. int b_index = 0;
  23.  
  24. while (a_index < n && b_index < m)
  25. {
  26. if (a[a_index] < b[b_index])
  27. {
  28. sb.Append(a[a_index++] + " ");
  29. }
  30. else
  31. {
  32. sb.Append(b[b_index++] + " ");
  33. }
  34. }
  35.  
  36. while (a_index < n)
  37. {
  38. sb.Append(a[a_index++] + " ");
  39. }
  40.  
  41. while (b_index < m)
  42. {
  43. sb.Append(b[b_index++] + " ");
  44. }
  45.  
  46. Console.Write(sb.ToString());
  47.  
  48. sr.Close();
  49. Console.ReadLine();
  50. }
  51. }
  52. }
Success #stdin #stdout 0.03s 24992KB
stdin
4 3
2 3 5 9
1 4 7
stdout
1 2 3 4 5 7 9