Pl help debugging my code
@spagire4
Let suppose you are at ith position and maximum weighted subsequence ended at that ith position then what you need is previous maximum weighted subsequence weight ended in 0âŠi-1 th index, if previous maximum weighted subsequence ending is smallest than the current a[i], you need to update maximum subsequence till now but there may be many indices where the elements are smaller than a[i], so all you have to do is to get the maximum of previously maximum ending subsequence using BIT or you can also use segment tree and make up your answer for current index.
You can see the implementation here for better understanding
1 Like
Thanks mam ,explanation provided by u is great and the way u implemented coordinate compression is superb
1 Like