Advertisement
noshin98

uva 591

Jul 1st, 2016
214
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.51 KB | None | 0 0
  1. #include<stdio.h>
  2. int main()
  3. {
  4.     int n,i,h[100],av,sum,ans,count=1;
  5.     while(scanf("%d",&n)==1&&n!=0)
  6.     {
  7.         sum=0;
  8.         for(i=1;i<=n;i++)
  9.         {
  10.             scanf("%d",&h[i]);
  11.             sum=sum+h[i];
  12.         }
  13.         av=sum/n;
  14.         ans=0;
  15.         for(i=1;i<=n;i++)
  16.         {
  17.             if(h[i]>av)
  18.             {
  19.                 ans=ans+h[i]-av;
  20.             }
  21.         }
  22.         printf("Set #%d\nThe minimum number of moves is %d.\n\n", count++, ans);
  23.     }
  24.     return 0;
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement