problem::http://www.codechef.com/problems/FLIPCOIN/
solution::http://www.codechef.com/viewsolution/4164335
plz help I am again and again getting TLE
problem::http://www.codechef.com/problems/FLIPCOIN/
solution::http://www.codechef.com/viewsolution/4164335
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: