591 - Box of Bricks

All about problems in Volume 5. If there is a thread about your problem, please use it. If not, create one with its number in the subject.

Moderator: Board moderators

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

Re: 591

Post by faiem »

"Output a blank line after each set."
Read this Carefully...its a problem about input/Output...

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

Post by valkov »

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

Post by tzupengwang »

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

Post by tzupengwang »

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
Location: Dhaka, Bangladesh
Contact:

Re: 591-Box of bricks

Post by uvasarker »

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

Post by tzupengwang »

Thanks a lot~
Finally AC after 2 WAs.

enamsustcse
New poster
Posts: 9
Joined: Fri May 04, 2012 9:41 pm
Location: SUST, Sylhet, Bangladesh
Contact:

Re: 591-Box of bricks

Post by enamsustcse »

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

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

591 Box of Bricks

Post by xtine.m »

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

Post by brianfry713 »

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

Post by xtine.m »

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

Post by winnfield »

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

Post by brianfry713 »

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

Post by winnfield »

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)

Post by milseg »

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)

Post by brianfry713 »

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!

Post Reply

Return to “Volume 5 (500-599)”