-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathboj11728.cpp
More file actions
46 lines (42 loc) · 818 Bytes
/
boj11728.cpp
File metadata and controls
46 lines (42 loc) · 818 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#include <iostream>
#include <vector>
using namespace std;
int N, M;
vector<int> arr1;
vector<int> arr2;
vector<int> total;
int nidx, midx;
int main() {
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
cin >> N >> M;
int temp;
for (int i = 0; i < N; i++) {
cin >> temp;
arr1.push_back(temp);
}
for (int i = 0; i < M; i++) {
cin >> temp;
arr2.push_back(temp);
}
while (nidx < N && midx < M) {
if (arr1[nidx] <= arr2[midx]) {
total.push_back(arr1[nidx++]);
}
else {
total.push_back(arr2[midx++]);
}
}
if (nidx < N) {
while (nidx != N) {
total.push_back(arr1[nidx++]);
}
}
if (midx < M) {
while (midx != M) {
total.push_back(arr2[midx++]);
}
}
for (int i = 0; i < total.size(); i++) {
cout << total[i] << ' ';
}
}