CANDYGAM - Editorial

Yup,You are correct. My solution is incorrect.

In Java… the VM by default allows a maximum allocation of 64MB.

@codersrikant that was true for old JVM, actually it’s something like 1/4 of RAM - http://stackoverflow.com/questions/4667483/how-is-the-default-java-heap-size-determined

The question was about stack size - http://www.onkarjoshi.com/blog/209/using-xss-to-adjust-java-default-thread-stack-size-to-save-memory-and-prevent-stackoverflowerror/

And in this thread EgorK asked to increase stack size (without response).

1 Like

Thank you betlista for the info.

@betlista I am sorry but I do not know about the stack size issue in JAVA. I would certainly like to help bringing it to attention.

The JAVA stack size is left to the default in both Pyramid and Cube.

Why was this not an issue on pyramid? Or it was and we didn’t notice it for 3 years?

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

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:

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

try this simple case:

1
1 1
1