EGBOBRD - Editorial

@gridhar_m yes you are right…i checked My AC soln and your concept too

suppose i open the first packet and take 3 breads and let the topmost bread remain there…
then the next day i take 3 breads from second packet and let the topmost bread remain there…
next day i remove the bad bread and also 2 breads from 1st packet.
and next day i remove the bad bread and also 2 breads from 2nd packet…

As only the piece that is exposed to mold is wasted only two packets must be used…

I don’t think that we will eat Ai bread and throw the next bread that is exposed then and there… it is pointless, as another piece of bread will be exposed(More wastage). it is only when we eat the next day or later in the tour that we throw the bad bread. And if only the last piece of bread is wasted then 3 3 2 2 should give 2 optimally.

The question is even if there is a last piece of bad bread, will the 2nd last piece also go bad…
Clarity of the question is questionable… :stuck_out_tongue:

I got only 15 pts. Can somebody check my code plz.

Atleast let me know the test cases that are failing. Thanks in advance.

I got 75 pts
And my only wrong answer is Sub-task 2 Task#3
Plz tell me which test case is my code not satisfying.

#include<stdio.h>
#include<math.h>
int main(void)
{short int T;
scanf("%hd",&T);
while(T>0)
{
int n,i;
scanf("%d",&n);
long long int k,j=0;
scanf("%lld",&k);
int a[n];
for(i=0;i<n;i++)
{
scanf("%d",&a[i]);
j+=a[i];
if(a[i]%k!=0 && i!=n-1 && j%k!=0)
{j++;}

    }
    if(j%k==0)
    {printf("%lld\n",(j/k));}
    else
    {printf("%lld\n",(j/k+1));}
    T--;
   }
return 0;

}

They eat acc. to daily requirement. So go on adding the no of breads they eat daily AND add 1(bread that damages daily). Don’t add 1 bread if(sum%k==0), because on that day no bread will remain. THUS, print sum/k or (sum/k)+1
which gives total no of packets required for throught the trip. TOO SIMPLE :slight_smile:

SOLUTION: CodeChef: Practical coding for everyone

Why this code gave WA…Please help

Can anyone take a look at my submission.
CodeChef: Practical coding for everyone.
i am taking an array dp[] which contains the no of of packages opened after each day and another array left[] which contains no of left over breads after each day
i am getting just one WA in subtask 2.

Hey Thanks this is useful coding link… Thanks for sharing…

Netsuite Partners

@tejasvi96 this is because you have to use long long. check your code, CodeChef: Practical coding for everyone , I just changed type to long long

thanx for the help avmnusng…

Please HELP HELP …Me out…I have tried most of the test cases…

Can we know the testcases used by judge please ?

Yes answer is 3.

Try this:
1
5 4
6 3 5 1 6

Answer should be 6. Your code gives 7.

Thank You Very much

But bhambya what is the value of K , N (i.e no of days and bread in each package…)…Please tell me that…

actually the new line didnt come there. T = 1, N = 5, K = 4, array : 6 3 5 1 6

Thank You Very Much For Your Kind Info… :slight_smile:

Thanks a lot bhambya

Job done with only few variables.