Help with PLPROCESS

Can some one explain why this is failing ?
https://www.codechef.com/viewsolution/59345763

You are initializing the answer with INT_MAX. The answer can be greater than that. Either initialize the answer with LLONG_MAX or with the sum of the array.

1 Like

Continuing the discussion from Help with PLPROCESS:

Can someone explain why this is solution is wrong?
https://www.codechef.com/viewsolution/59370446

you are initializing the sum to be a global variable for all testcases, the sum should be testcase specific. For ex: for the first test case you calculate the sum, Ideally in second test case you have to reset the sum to zero, but in your code the sum of previous iteration is getting carry forwarded to the next test case, which is causing your test cases failure.