How to overcome TLE on Energetic Node

Problem name: Energetic Node(Hard Version) .
Problem link: CodeChef
I am trying to solve this problem but each time I get TLE .
My solution: CodeChef
Would anyone like to tell me what changes should I bring in my code to overcome the TLE issue?
Thanks for your help.