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

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

Re: 591 - Box Of Bricks (WA)

Post by milseg »

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

Post by ehsanulbigboss »

Got Accepted!!!
Last edited by ehsanulbigboss on Fri Jul 25, 2014 10:42 pm, edited 1 time in total.
lighted
Guru
Posts: 587
Joined: Wed Jun 11, 2014 9:56 pm
Location: Kyrgyzstan, Bishkek

Re: 591 - Box of Bricks

Post by lighted »

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
Output a blank line after each set.
Btw, you must post about this problem in Volume V.
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

Post by This Is ERFAN »

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

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

Post by utpal.ruetcse13 »

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"
Post Reply

Return to “Volume 5 (500-599)”