Advertisement
yuawn

algo2017_week9_bricks

Nov 29th, 2017
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.39 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. #define fo(n) for(int i=0;i<n;i++)
  4. #define fos(o,n) for(int i=o;i<=n;i++)
  5.  
  6.  
  7. int main(){
  8.     int T;
  9.    
  10.     cin >> T;
  11.    
  12.     while( T-- ){
  13.        
  14.         int n , avg = 0 , x[777] , ans = 0;
  15.        
  16.         cin >> n;
  17.        
  18.         fo( n ) cin >> x[i] , avg += x[i];
  19.        
  20.         avg /= n;
  21.        
  22.         fo( n ) ans += max( 0 , x[i] - avg );
  23.        
  24.         cout << ans << endl;
  25.     }
  26.    
  27.     return 0;
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement