591 - Box of Bricks
Moderator: Board moderators
Re: 591
"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....
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....
-
- 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;
}
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;
}
-
- 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~
could anyone help me?
THANKS~
-
- Learning poster
- Posts: 96
- Joined: Tue Jul 19, 2011 12:19 pm
- Location: Dhaka, Bangladesh
- 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);
printf("Set #%d",c);
printf("\nThe minimum number of moves is %d.\n\n",q);
-
- 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.
Finally AC after 2 WAs.
-
- New poster
- Posts: 9
- Joined: Fri May 04, 2012 9:41 pm
- Location: SUST, Sylhet, Bangladesh
- Contact:
Re: 591-Box of bricks
Thanx a lot,,
I have just mistaken it for last several attepmts...
but now..
I have just mistaken it for last several attepmts...
but now..

-----
Enamul Hassan,
Student,
2nd year, CSE,
SUST, Sylhet, Bangladesh
Enamul Hassan,
Student,
2nd year, CSE,
SUST, Sylhet, Bangladesh
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.
-
- 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) {
Change line 13 to:
while (scanf("%d",&c) == 1 && c != 0) {
Check input and AC output for thousands of problems on uDebug!
Re: 591 Box of Bricks
Thank you! just deleted my codes.. Just got accepted!!
591 - Box of bricks
SOLVED
NOTHING TO SEE HERE
NOTHING TO SEE HERE
Last edited by winnfield on Tue Jun 11, 2013 4:59 am, edited 1 time in total.
-
- 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!
Re: 591 - Box of bricks
I feel so stupid right now...brianfry713 wrote:print minimum not minumum
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.
-
- 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:AC output:
Input:
Code: Select all
4
1 1 3 3
0
Code: Select all
Set #1
The minimum number of moves is 2.
Check input and AC output for thousands of problems on uDebug!