fork download
  1. #include <iostream>
  2. #include <vector>
  3. using namespace std;
  4.  
  5. int main() {
  6.  
  7. ios_base::sync_with_stdio(0);
  8. cin.tie(0);
  9.  
  10. int n;
  11. cin >> n;
  12.  
  13. vector<int> ted(n);
  14.  
  15. for (int i = 0; i < n; i++) {
  16. cin >> ted[i];
  17. }
  18.  
  19. int x = 0;
  20.  
  21.  
  22. for (int i = 0; i < n; i++) {
  23. if (ted[i] != 0) {
  24. if (x == 0 || ted[i] < x) {
  25. x = ted[i];
  26. }
  27. }
  28. }
  29.  
  30. cout << x << endl;
  31.  
  32.  
  33. for (int i = 0; i < n; i++) {
  34. if (ted[i] != 0) {
  35. cout << ted[i] - x << " ";
  36. } else {
  37. cout << 0 << " ";
  38. }
  39. }
  40.  
  41. return 0;
  42. }
Success #stdin #stdout 0s 5308KB
stdin
5
3 4 3 5 0

stdout
3
0 1 0 2 0