-
Notifications
You must be signed in to change notification settings - Fork 0
/
530.cpp
71 lines (53 loc) · 1.03 KB
/
530.cpp
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#include <iostream>
using namespace std;
int main()
{
int n, m, k = 1, a[100001], b[100001], c[200002];
cin >> n;
for(int i = 1; i <= n; i++)
cin >> a[i];
cin >> m;
for(int j = 1; j <= m; j++)
cin >> b[j];
int i = 1;
int j = 1;
while(i <= n && j <= m) {
if(a[i] > b[j]) {
c[k] = b[j];
j++;
}
else {
c[k] = a[i];
i++;
}
k++;
}
while(i <= n) {
c[k] = a[i];
i++;
k++;
}
while(j <= m) {
c[k] = b[j];
j++;
k++;
}
int last = -1;
int x = 0, y = 0, un[200002], in[10001];
for(int l = 1; l <= m + n; l++) {
if(last != c[l]) {
x++;
un[x] = c[l];
} else {
y++;
in[y] = c[l];
}
last = c[l];
}
for(int l = 1; l <= x; l++)
cout << un[l] << " ";
cout << endl;
for(int l = 1; l <= y; l++)
cout << in[l] << " ";
return 0;
}