Hi guys,
I am stunned at problem CSES sliding window advertisement,my idea is I can use monotonic stack to find the element $$$pre[i]$$$ and $$$next[i]$$$ which is the last and next element which strictly less than element $$$a[i]$$$ but i only find the maximum area for only one window and i can't maintain next window by current window,the second idea i come through is segment tree,i observe that assume we have to segment $$$[l,mid]$$$ and $$$[mid+1,r]$$$ then there is 3 condition happen which is maximum area occcur in left segment/right segment/cross over two segment,but also i can't really maintain the maximum area which cross over two segment.
I need some idea or tips,if you know please feel free to teach me,i will appreciate.
Problem link:Cses








