MAXSCOR https://www.codechef.com/problems/MAXSCOR

https://www.codechef.com/viewsolution/44321836

can anybody help me ?
whether my approch is wrong or right?
if right then why it is not passing all test cases?