Today I was trying to solve some questions from codechef and I ran into this question. I tried to optimise it in different ways but I failed in every attempt. The problem statement is here. I am getting TLE on my submission here. Can someone help by giving me a rough idea on solving this question? Thank You...:)