## 591 - Box of Bricks

Moderator: Board moderators

faiem
New poster
Posts: 14
Joined: Fri Aug 13, 2010 12:22 pm

### Re: 591

"Output a blank line after each set."

ur Output should look like.......

6
5 2 4 1 7 5
Set #1
The minimum number of moves is 5.

4
5 10 3 2
Set #2
The minimum number of moves is 5.

0

Wish ur best luck....

valkov
New poster
Posts: 20
Joined: Tue Jul 20, 2010 3:11 pm

### Re: 591

faiem wrote:why u r sorting???
it is possible without sorting...and very fast...
Yes. You are right, no sorting is needed

tzupengwang
New poster
Posts: 36
Joined: Fri Dec 02, 2011 1:30 pm
Location: Kaohsiung, Taiwan

### 591 - Box of Bricks

could anyone tell me why I got WA??
the following is my source code.
/*591*/
#include<stdio.h>
#include<string.h>
int main()
{
int k,a;
for(k=1;scanf("%d",&a)==1;k++)
{if(!a)break;
int str[a],i;
for(i=0;i<a;i++)
{scanf("%d",&str);}
int sum,aver,m;
for(i=0,sum=0;i<a;i++)
{sum+=str;}
aver=sum/a;
for(i=0,sum=0;i<a;i++)
{if(aver>str){m=aver-str;
sum+=m;}
}
printf("Set #%d\n",k);
printf("The minimum number of moves is %d.\n",sum);
}
return 0;
}

tzupengwang
New poster
Posts: 36
Joined: Fri Dec 02, 2011 1:30 pm
Location: Kaohsiung, Taiwan

### Re: 591-Box of bricks

I tried several times and it went well,
could anyone help me?
THANKS~

uvasarker
Learning poster
Posts: 96
Joined: Tue Jul 19, 2011 12:19 pm
Contact:

### Re: 591-Box of bricks

print double new line such as mine:
printf("Set #%d",c);

printf("\nThe minimum number of moves is %d.\n\n",q);

tzupengwang
New poster
Posts: 36
Joined: Fri Dec 02, 2011 1:30 pm
Location: Kaohsiung, Taiwan

### Re: 591-Box of bricks

Thanks a lot~
Finally AC after 2 WAs.

enamsustcse
New poster
Posts: 9
Joined: Fri May 04, 2012 9:41 pm
Contact:

### Re: 591-Box of bricks

Thanx a lot,,
I have just mistaken it for last several attepmts...
but now..
-----
Enamul Hassan,
Student,
2nd year, CSE,

xtine.m
New poster
Posts: 6
Joined: Tue May 08, 2012 5:36 pm

### 591 Box of Bricks

Can anyone tell me why I got a Time Limit Exceeded?
Last edited by xtine.m on Fri Jan 25, 2013 1:57 pm, edited 1 time in total.

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

### Re: 591 Box of Bricks

Try running your code on the sample input.
Change line 13 to:
while (scanf("%d",&c) == 1 && c != 0) {
Check input and AC output for thousands of problems on uDebug!

xtine.m
New poster
Posts: 6
Joined: Tue May 08, 2012 5:36 pm

### Re: 591 Box of Bricks

Thank you! just deleted my codes.. Just got accepted!!

winnfield
New poster
Posts: 2
Joined: Mon Jun 10, 2013 10:52 pm

### 591 - Box of bricks

SOLVED

NOTHING TO SEE HERE
Last edited by winnfield on Tue Jun 11, 2013 4:59 am, edited 1 time in total.

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

### Re: 591 - Box of bricks

print minimum not minumum
Check input and AC output for thousands of problems on uDebug!

winnfield
New poster
Posts: 2
Joined: Mon Jun 10, 2013 10:52 pm

### Re: 591 - Box of bricks

brianfry713 wrote:print minimum not minumum
I feel so stupid right now...

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

### 591 - Box Of Bricks (WA)

Hello! I've tested this problem with a lot of inputs and it seems like i get correct answers. Tough it isn't working in the submission system, cause it raises wrong answer. Could someone tell me where is the error on my Source Code. Here it is:

Code: Select all

``````DELETED
``````
Last edited by milseg on Tue Jul 08, 2014 5:57 am, edited 1 time in total.

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

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

Don't use a set.
Input:

Code: Select all

``````4
1 1 3 3
0
``````
AC output:

Code: Select all

``````Set #1
The minimum number of moves is 2.

``````
Check input and AC output for thousands of problems on uDebug!