UVa 591 - Box of Bricks

#include<stdio.h>
int main()
{
    int n,i,count,sum,p,set=0;
    int br[100];
    while(scanf("%d",&n)==1 && n!=0)
    {
        sum=0;
        count=0;
        for(i=0;i<n;i++)
            scanf("%d",&br[i]);
        for(i=0;i<n;i++)
            sum+=br[i];
        p=sum/n;
        for(i=0;i<n;i++)
        {
            if(br[i]>p)
            {
                count+=(br[i]-p);
            }
        }
        printf("Set #%d\nThe minimum number of moves is %d.\n\n",++set,count);
    }
    return 0;
}
Share on Google Plus

About Unknown

This is a short description in the author block about the author. You edit it by entering text in the "Biographical Info" field in the user admin panel.
    Blogger Comment
    Facebook Comment

0 মন্তব্য(গুলি):

একটি মন্তব্য পোস্ট করুন