591 - Box of Bricks
Moderator: Board moderators
Re: 591 - Box Of Bricks (WA)
Right. It makes sense, since they can have the same height. Thank you very much!
-
- 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.
Re: 591 - Box of Bricks
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
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
Btw, you must post about this problem in Volume V.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
-
- New poster
- Posts: 6
- Joined: Thu Dec 04, 2014 11:40 pm
Re: 591 Box of Bricks
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;
}
-
- 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!
-
- 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![:)](./images/smilies/icon_smile.gif)
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"
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
![:)](./images/smilies/icon_smile.gif)
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"