#include <iostream>
using namespace std;
int a[1000001];
int b[1000001];
int c[1000001];
int main(void) {
       int n1, n2;
       cin >> n1 >> n2;
       for (int i = 0; i<n1; ++i) {
              cin >> a[i];
       }
       for (int i = 0; i<n2; ++i) {
              cin >> b[i];
       }
       int start = 0;
       int end = n1 + n2 - 1;
       int mid = (start + end) / 2;
       int k = 0;
       int i = 0;
       int j = 0;
       while (i < n1 && j < n2) {
              if (a[i] < b[j]) {
                     c[k++] = a[i++];
              }
              else {
                     c[k++] = b[j++];
              }
       }
       while (i<n1) c[k++] = a[i++];
       while (j<n2) c[k++] = b[j++];
       for (int i = 0; i<k; ++i) {
              cout << c[i] << ' ';
       }
       return 0;
}


'알고리즘' 카테고리의 다른 글

[DC] 백준 11729 하노이의 탑 이동순서  (0) 2018.04.29
[DC] 백준 6236 용돈관리  (0) 2018.04.29
[DC] 백준 1780 종이의 개수  (0) 2018.04.29
[BS] 백준 2512 예산  (0) 2018.04.29
[BS] 백준 1939 중량제한  (0) 2018.04.29

+ Recent posts