TLE in CONSESNK

CONSESNK
why am I getting TLE? CodeChef: Practical coding for everyone

Not able to find the flaw in your code, still refer this and match your approach if possible.
EDITORIAL.
I hope this helps. :slight_smile:

You have a for loop which runs from 0 to n (which can be 10^5) inside a loop which runs from a to a+n*l with an increment of l, which makes it equal to running n times. So the total complexity of your solution is O(n^2) since n is 10^5, that will take 10^10 operations which will not fit in the time limit.