POJ1949

#include <iostream>
using namespace std;

const int MAX_SIZE = 52;

int height[MAX_SIZE];

int main()
{
    
int i,n,tt = 0,sum,cnt;
    
while(cin>>&& n)
    
{
        sum 
= cnt = 0;
        
for(i = 0; i < n; i++)
        
{
            cin
>>height[i];
            sum 
+=height[i];
        }

        sum 
/= n;
        
for(i = 0; i < n; i++)
            
if(height[i] > sum)
                cnt 
+= height[i] - sum;
        cout
<<"Set #"<<++tt<<endl;
        cout
<<"The minimum number of moves is "<<cnt<<"."<<endl<<endl;
    }

    
return 0;
}

posted on 2009-02-28 14:23  Xredman  阅读(191)  评论(0编辑  收藏  举报

导航