getting TLE in MasterChef after using segment trees. Can anyone help?
Can anyone tell me why am I getting tle after using segment trees as discussed in tutorial. What I have done is that during update if I get a segment completely in the range I just check for segment value ,and update it and then return. Then I placed the min cost for each index in an array named min_cost and applied knapsack.

May be you are passing too many variables in the recursive tree function. Have a look at my solution mySolution for further details.