文章
19
粉丝
21
获赞
5
访问
19.0k
// 用归并排序的思想合并即可
# include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 10;
int a[N],b[N];
vector<int> ans;
int main (void){
int n,m;
cin >> n;
for (int i = 1; i <= n; ++i) scanf("%d",&a[i]);
cin >> m;
for (int i = 1; i <= m; ++i) scanf("%d",&b[i]);
int i,j;
for (i = 1,j = 1; i <= n && j <= m;){
if (a[i] <= b[j]){
ans.push_back(a[i]);
i ++;
}else{
ans.push_back(b[j]);
j ++;
}
}
while (i <= n) ans.push_back(a[i ++]);
while (j <= m) ans.push_back(b[j ++]);
int cnt = (ans....
登录后发布评论
暂无评论,来抢沙发