## 591 - Box of Bricks

Moderator: Board moderators

milseg
New poster
Posts: 4
Joined: Mon Jul 07, 2014 8:05 pm

### Re: 591 - Box Of Bricks (WA)

Right. It makes sense, since they can have the same height. Thank you very much!

ehsanulbigboss
New poster
Posts: 32
Joined: Tue Jul 22, 2014 1:17 am

### 591 - Box of Bricks

Got Accepted!!!
Last edited by ehsanulbigboss on Fri Jul 25, 2014 10:42 pm, edited 1 time in total.

lighted
Guru
Posts: 585
Joined: Wed Jun 11, 2014 9:56 pm
Location: Kyrgyzstan, Bishkek

### Re: 591 - Box of Bricks

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.
A person who sees the good in things has good thoughts. And he who has good thoughts receives pleasure from life... Bediuzzaman

This Is ERFAN
New poster
Posts: 6
Joined: Thu Dec 04, 2014 11:40 pm

### Re: 591 Box of Bricks

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;
}
``````

brianfry713
Guru
Posts: 5947
Joined: Thu Sep 01, 2011 9:09 am
Location: San Jose, CA, USA

### Re: 591 - Box of Bricks

Output a blank line after each set.
Check input and AC output for thousands of problems on uDebug!

utpal.ruetcse13
New poster
Posts: 1
Joined: Wed Dec 31, 2014 8:50 pm

### Re: 591 - Box of Bricks

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"