-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path11728.cpp
More file actions
36 lines (29 loc) · 712 Bytes
/
11728.cpp
File metadata and controls
36 lines (29 loc) · 712 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
#include <cstdio>
int main(){
long long int as, bs;
scanf("%lld %lld", &as, &bs);
long long a[as], b[bs];
for(long long int i=0;i<as;i++) scanf("%lld", &a[i]);
for(long long int i=0;i<bs;i++) scanf("%lld", &b[i]);
long long int c[as+bs];
long long int ap=0, bp=0;
while(ap<as || bp<bs){
if(ap==as){
c[ap+bp]=b[bp];
bp++;
}
else if(bp==bs){
c[ap+bp]=a[ap];
ap++;
}
else if(a[ap]<b[bp]){
c[ap+bp]=a[ap];
ap++;
}
else{
c[ap+bp]=b[bp];
bp++;
}
}
for(long long int i=0;i<as+bs;i++) printf("%lld ", c[i]);
}