I have spent a couple of hours on the task BESTSUM: https://www.codechef.com/problems/BESTSUM
Eventually, I have got AC, but I think that the problem is very likely to be incorrect. It has a low accepted rate (for a relatively easy problem), and there are no constraints on K, P and Ai. I assumed them to be long longs, but I got AC after changing them to ints! The other parts of the code are exactly the same. Check out my submissions: https://www.codechef.com/viewsolution/16149420 (WA) and https://www.codechef.com/viewsolution/16149346 (AC). It seems that there is an overflow in tests.
Hopefully, this problem will be corrected or removed. At least someone struggling with the problem could find this post