fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. int main() {
  5. int N;
  6. cin >> N;
  7. vector<int> A(N);
  8.  
  9.  
  10. for(int i=0; i<N; i++){
  11. cin >> A.at(i);
  12. }
  13.  
  14. int total=0,mean;
  15.  
  16. for(int i=0; i<N; i++){
  17. total += A.at(i);
  18. }
  19.  
  20. mean = total / N;
  21.  
  22. for(int i=0; i < N; i++){
  23. if(A.at(i)>=mean){
  24. cout << A.at(i)-mean << endl;
  25. }else{
  26. cout << mean-A.at(i) << endl;
  27. }
  28. }
  29. }
Success #stdin #stdout 0.01s 5320KB
stdin
10
53 21 99 83 75 40 33 62 18 100
stdout
5
37
41
25
17
18
25
4
40
42