fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. const int MAX_LENGTH = 100;
  5.  
  6. int main() {
  7. int n, v[MAX_LENGTH + 1], w[MAX_LENGTH + 1], dif[MAX_LENGTH + 1];
  8. cin >> n;
  9. for (int i = 1; i <= n; ++i) {
  10. cin >> v[i];;
  11. }
  12. for (int i = 1; i <= n; ++i) {
  13. cin >> w[i];
  14. }
  15.  
  16. for (int i = 1; i < n; ++i) {
  17. for (int j = i + 1; j <= n; ++j) {
  18. if (w[i] > w[j]) {
  19. int aux = w[i];
  20. w[i] = w[j];
  21. w[j] = aux;
  22. }
  23. }
  24. }
  25.  
  26. int diference = v[1] - w[1];
  27. int flag = 1, index = 1;
  28. dif[index] = v[1] - w[1];;
  29. for (int i = 2; i <= n; ++i) {
  30. if (v[i] - w[i] != diference) {
  31. dif[index] = v[i] - w[i];
  32. ++index;
  33. flag = 0;
  34. }
  35. }
  36. if (flag == 1 || index != 1) {
  37. cout << "DA\n";
  38. for (int i = 1; i <= index; ++i) {
  39. cout << dif[i] <<" ";
  40. }
  41. } else {
  42. cout << "NU";
  43. }
  44. return 0;
  45. }
Success #stdin #stdout 0s 5316KB
stdin
5
1 2 3 4 5
3 2 2 -1 0
stdout
DA
1 0