Regarding max-sum-k-partition

Why my code is not passing every test case? What is the problem?