Untitled
NguyenAnhQuan
c_cpp
2 years ago
640 B
7
Indexable
#include <bits/stdc++.h>
#define ll long long
#define LIM 1000005
#define X first
#define Y second
#define EL cout<<"\n"
using namespace std;
int a[LIM], b[LIM], c[LIM];
int main()
{
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int n; cin >> n;
for (int i = 0; i < n; i++) cin >> a[i];
int m; cin >> m;
for (int i = 0; i < m; i++) cin >> b[i];
int pa = 0, pb = 0, k = 0;
a[n] = 2e9; b[m] = 2e9;
while (k < n + m)
{
if (a[pa] < b[pb]) c[k] = a[pa++];
else c[k] = b[pb++];
k++;
}
for (int i = 0; i < n + m; i++)
cout << c[i] << " ";
return 0;
}Editor is loading...
Leave a Comment