Page 6 of 6

Re: 591 - Box Of Bricks (WA)

Posted: Tue Jul 08, 2014 5:54 am
by milseg
Right. It makes sense, since they can have the same height. Thank you very much!

591 - Box of Bricks

Posted: Fri Jul 25, 2014 9:56 pm
by ehsanulbigboss
Got Accepted!!!

Re: 591 - Box of Bricks

Posted: Fri Jul 25, 2014 10:34 pm
by lighted
You must search topics about your problem first.
Insert problem number 591 into search box and you will get many explanations why your code may get WA.
http://acm.uva.es/board/search.php?keyw ... f7e91186d6
Output a blank line after each set.
Btw, you must post about this problem in Volume V.

Re: 591 Box of Bricks

Posted: Tue Dec 09, 2014 12:14 am
by This Is ERFAN
Getting wrong answer....Help me plz

Code: Select all

#include<stdio.h>

int main()
{
    int num,i,m,j,k;
    for(m=1;; m++)
    {
        scanf("%d",&num);
        if(num==0) return 0;
        int arr[num];
        for(i=0; i<num; i++)
        {
            scanf("%d",&arr[i]);
        }
        int sum=0;
        for(j=0; j<num; j++)
        {
            sum=sum+arr[j];
        }
        int size=sum/num;
        int count=0;
        for(k=0; k<num; k++)
        {
            if(arr[k]>size) count=count+(arr[k]-size);
            else
                continue;
        }

            printf("Set #%d\nThe minimum number of moves is %d.\n",m,count);
    }

    return 0;
}

Re: 591 - Box of Bricks

Posted: Wed Dec 10, 2014 12:36 am
by brianfry713
Output a blank line after each set.

Re: 591 - Box of Bricks

Posted: Wed Dec 31, 2014 9:04 pm
by utpal.ruetcse13
faced lots of WA because of missing a new line.......
Here those are facing to solve this problem, please be confirmed you have entered a blank line. so in that case you have to put two new lines :)
Thats it!!!!!
Like my code is -
cout<<"Set #"<<num<<endl;
cout<<"The minimum number of moves is "<<moves<<".\n\n";
// I've used #include <cstdio> as header file so i used "\n"