CANDYGAM - Editorial

it seems, that for this input

1
4 4
34 70 66 56
94 89 22 67
22  9 26 79
30 78 73 63

your code returns 554, my returns 528.

hey i tested my code again. This is my code :
http://www.codechef.com/viewsolution/1514495
But iā€™m getting 528, i guess same as you.
Thanks anyways :slight_smile:

Sorry I wrote it swapped, my code returns 554 and thatā€™s more than 528.

If I try simple min max strategy: steps

A takes first column +180 (A=180)
B takes last column +265 (B=265)
A takes first row +136 (A=362)
B takes first column +177 (B=442)
A takes first row +22 (A=384)
B takes all remaining candies +121 (B=541)

so B can take at least 541 candies (and itā€™s not optimal still)

tried each and every test case (even given in the comments above) still getting wrong answerā€¦ Here is my code http://www.codechef.com/viewsolution/1556684 Can anyone tell whats wrong?

1 Like

tried each and every test case (even given in the comments above) still getting wrong answerā€¦ Here is my


[1] Can anyone tell whats wrong?


  [1]: http://ideone.com/4CReZE

Woe is a template that has an INF and a BIG_INF, where you forget to think for a moment which one should you use :stuck_out_tongue:

(I hope the poetic expression gave away what was wrong in your code. It gets AC here after this small change)

2 Likes

@gamabunta- dude only one thing to say, you are just excellent.Excellent coding analysing ability.Itne chote se error ne dimag kharab kar rakha tha subah se. :slight_smile:

Is there a possibility that bob leaves greater candies of some row now but get more candies in the end than he might have got if he had taken greater candies in the preceding steps ??

If this is true, then we would have to go through all the combinations of bob as presented in the solution. I went through only cases having largest number of candies among current 4 choices .

my code

Yes, there is such possibility, I added few of them here f.e.:

1
4 4
83 43 69 43
35 45 39 33
 9 76 39 55
22 88 58 60

your code returns 497, correct answer is 503.

also

1
4 4
34 70 66 56
94 89 22 67
22  9 26 79
30 78 73 63

your code returns 540, correct answer is 554.

1 Like

can anyone plz help me with my


[1].I m getting correct answer for every testcase given above but codechef is showing wrong answer.  


  [1]: http://www.codechef.com/viewsolution/1566581

try this simple case:

1
1 1
1

thanks a lot betlistaā€¦I got my mistakeā€¦I modified my


[1] so that it now prints winner's candies not bob's candies but still I m getting a wrong answer.

  [1]: http://www.codechef.com/viewsolution/1567165

Heyy Iā€™ve solvd this problem and somehow Iā€™m not able to get why itā€™s giving me a wrong answer hereā€¦would you kindly check the code???
http://www.codechef.com/viewsolution/1693143