september long challenge.
i think my code is right but why i am getting TLE after 1st test cases.
plz suggest me .
following is my code link https://www.codechef.com/viewsolution/15327071
Look the problem isn’t that your code is not right, it’s just that its is not efficient. I mean your time complexity is O(n*n) which takes you out of the time limit provided in the question. You need to think of of O(nlogn) solution. If you dont know about segment trees ,google it and learn it.
Feel free to ask if you don’t get what I am talking about!