Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- int main()
- {
- int n,i,h[100],av,sum,ans,count=1;
- while(scanf("%d",&n)==1&&n!=0)
- {
- sum=0;
- for(i=1;i<=n;i++)
- {
- scanf("%d",&h[i]);
- sum=sum+h[i];
- }
- av=sum/n;
- ans=0;
- for(i=1;i<=n;i++)
- {
- if(h[i]>av)
- {
- ans=ans+h[i]-av;
- }
- }
- printf("Set #%d\nThe minimum number of moves is %d.\n\n", count++, ans);
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement