Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <fstream>
- using namespace std;
- ifstream fin("date.in");
- int n, m, a[3001], b[3001], i, j, x, n1, m1;
- int main() {
- cin >> n >> m;
- for(i = 1; i <= n; i ++) {
- cin >> x;
- if(x % 2 == 0)
- a[++ n1] = x;
- }
- for(j = 1; j <= m; j ++) {
- cin >> x;
- if(x % 2 == 0)
- b[++ m1] = x;
- }
- i = 1;
- j = m1;
- while(i <= n1 && j >= 1) {
- if(a[i] < b[j]) {
- cout << a[i] << " ";
- i ++;
- } else if(a[i] > b[j]) {
- cout << b[j] << " ";
- j --;
- } else {
- cout << a[i] << " " << b[j] << " ";
- i ++;
- j --;
- }
- }
- while(i <= n1) {
- cout << a[i] << " ";
- i ++;
- }
- while(j >= 1) {
- cout << b[j] << " ";
- j --;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement