Max of a segment with something new

Revision en1, by secomo, 2021-07-26 12:12:19

Hi..

Given an array a that containes 2n elements each element has han an occurrence of 2 in the array.

so {1,2,4,1,4,2} would be an example, Now we have Q queries each query is asking for the maximum element on the segment L...R,but if the element has 2 occurrences on the segment L...R it will not be counted.

so if a={1,2,4,1,4,2} and query={2,6} the answer will be 1 because 4 and 2 will not be counted.

I think I can solve this uning Mo algorithm but I want a segment tree aproach.

Any help would be great, Thank you for reading.

Tags #segment tree, #range query, maximum

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en1 English secomo 2021-07-26 12:12:19 587 Initial revision (published)