My code is getting WA in this problem -
My solution is -
https://www.codechef.com/viewsolution/40942257
My approach is - I used divide and conquer, so basically for every range I computed the prefix mins of right half and suffix min for left half and added them in 2 vectors for positions where there is a given B index, after that the way I counted the range-mins is while my left vector’s pointer is pointing to a smaller value then I increment the right pointer and vice versa, after that I add the position_of_right*value_in_left (vice versa) to my answer, and finally I add anything which is extra in any of the ranges.
Can someone explain the error?