SMARKET - Editorial

In the alternate view of problem-

Let us create another array B that denotes the lengths of the blocks of the array A. Number of elements in B will be equal to the number of blocks of the array A. For A=[20,10,10,7,7,7,10]the array B will be [1,3,2,1]
. 

Should it not be [1,2,3,1]? Am I missing something?

1 Like

I did everything in O(n+q) by pushing queries into a vector at location l and r and processing with line sweep

Credits to bluescorp for sharing a unique observation, we both had a O(Q*logN) algorithm ready before we communicated. My solution(AC 0.23s): https://www.codechef.com/viewsolution/13370003

Hi Guys!

Made a video editorial for this problem:

Stable Market - CodeChef April Long Challenge

Btw, I think is editorial is quite good, and it explains the approaches quite well. :slight_smile:

Cheers!

7 Likes

Yeah, seems like a typo.

Can someone explain the comments in code written by author @pkacprzak.
How did he decomposed query by calling (solve-strictly-inside8block) && (solve-left-boundary)

Thanks in advance !