fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main() {
  5. int n, m, v[100000], w[100000];
  6. cin >> n >> m;
  7. for (int i = 1; i <= n; ++i) {
  8. cin >> v[i];
  9. }
  10. for (int j = 1; j <= n - m; ++j) {
  11. cin >> w[j];
  12. }
  13. int aux[m];
  14. int z = 0, i = 1, j = 1;
  15. if(n==n-m){
  16. cout << "Nu s-au pierdut date";
  17. }
  18. if (n > m) {
  19. while (i <= n && z <= m) {
  20. if (v[i] != w[j]) {
  21. ++z;
  22. aux[z] = v[i];
  23. ++i;
  24. } else if (v[i] == w[j]) {
  25. ++i;
  26. ++j;
  27. } else {
  28. ++z;
  29. aux[z] = v[i];
  30. ++i;
  31. }
  32. }
  33. for (int z = 1; z <= m; ++z) {
  34. cout << aux[z] << " ";
  35. }
  36. }
  37. return 0;
  38. }
Success #stdin #stdout 0s 5276KB
stdin
7 2 
12 -100000 10 -87 10 34 -29
 -100000 10 -87 10 34 
 
 
 
stdout
12 -29