首页 > 代码库 > hdu2088

hdu2088

hdu2088

技术分享
 1 #include<stdio.h>
 2 #include<algorithm>
 3 using namespace std;
 4 int h[55];
 5 int main(){
 6     int N,t=0;
 7     while(scanf("%d",&N)!=EOF&&N!=0){
 8 
 9         int sum=0,q;
10         for(q=1;q<=N;q++){
11             scanf("%d",&h[q]);
12             sum+=h[q];
13         }
14         if(t++){printf("\n");}
15         int ave=sum/N;
16         sort(h+1,h+N+1);
17         int t=0;
18         for(q=N;h[q]>ave;q--)t+=(h[q]-ave);
19         printf("%d\n",t);
20     }
21     return 0;
22 }
View Code

 

hdu2088