I think my solution is similar to that given in the editorial but still I am getting WA.Can somebody please help me why am i getting WA by giving a test case ?

My soln-http://www.codechef.com/viewsolution/7432688

Hi Prerak Dholakiya:

after working on your solution i have found some test case on which your solution does not give correct answer

3

13 334

23 543 32 65 78 43 65 23 4565 432 78 12 1

9 11

89 1 7 34 2 64 23 98 12

8 13

14 14 14 14 14 14 14 14

your output 17,30,4 but correct output is 18,31,10

i know there is something wrong but i suggest you:

if you have extra bread then first of all decrement it if it is >0 then make any operation on extra bread

and if temp is total need on that day then why are you making extra+=((temp/k)+1)*k-temp-1; here you are just subtracting required bread from total bread then why â€ś-1â€ť it decrement extra although you have already decremented extra if it is >0

finally i cant read you mind(logic) but these are just suggestion what i think about it not correction

and PLZZZZ upvote if you got your test cases Because i cant ask any question due to low KARMA

I am decremented extra when extra>0.This means that temp is equal to 0 means on that all the bread at that on that day had been eaten.And there is still extra breads so one bread is decremented as it will be bad and will not be available for the next day.if extra=0 means no extra bread and now i will buy ceil(temp/k) packets and from that extra bread will be ceil(temp/k)*k-temp.And -1 for the wasted bread which will not be available for the next day.

You can have a look at my solution. http://www.codechef.com/viewsolution/7345415

Hope you understand it. If you have any difficulty, you can ask me.

hello Prerak Dholakiya

i have found what is problem in your solution finally

â€śYOU ARE NOT KEEPING INITIAL NEED OF BREAD OF THAT DAY ie. tempâ€ť

just declare one more variable temp1 and store the value of temp in temp1 and then use this value here extra-=Math.min(temp1,extra);

CODE LOOKS LIKE

long temp=input.nextLong();

temp1=temp;

temp-=Math.min(temp,extra);

extra-=Math.min(temp1,extra);

this is what which decrease your rank about 1700

thanks a lotâ€¦What a fool I amâ€¦