Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // bac_2020_var16_subIII_pb3
- #include <iostream>
- #include <fstream>
- using namespace std;
- ifstream fin("bac.in");
- ofstream fout("bac.out");
- int n,m,k, last = -1;
- int v[1000000];
- void afiseaza_val(int val)
- {
- if (val%2 != last%2) {
- fout << val << ' ';
- last = val;
- }
- }
- int main()
- {
- fin >> n >> m;
- for(int i=0; i<n; i++)
- fin >> v[i];
- int p=0;
- for(int i=0; i<m; i++)
- {
- fin >> k;
- while(v[p]<k){
- afiseaza_val(v[p]);
- p++;
- }
- afiseaza_val(k);
- }
- while (p<n) afiseaza_val(v[p++]);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement