This is a question from CodeChef. I have tried to code it. The code works on the custom inputs but not for the inbuilt inputs. Therefore, I request you to kindly point out my mistake.
Here is the link for the question:
https://www.codechef.com/FEB21C/problems/MAXFUN
Here is the link to my code: