TIME FOR SADVAL

https://www.codechef.com/viewsolution/27431437

In my solution, the time shown is 1.51 s, with the time limit being 1-2 s. So, why is it showing TLE?
Also, is there a better way to solve this problem than what I’ve done( I fixed the mid element and looked for smallest smaller element in left and smallest larger number in the right)?

Your approach is correct but try to optimize your implementation for finding minimum in left and smallest larger in right(hint : can use set or multiset)

Thank you.