TLE in FLIPCOIN

problem::FLIPCOIN Problem - CodeChef
solution::CodeChef: Practical coding for everyone

plz help I am again and again getting TLE

What I could make out from your code is that the complexity of your update function is O(n) …This is causing u TLE … you need to update the segment tree in log(n) time … this can be done using Lazy propogation in segment trees …Have a look at this article to learn more on segment trees:

1 Like