Where am I going wrong

getting wrong answer in modified lis question. Help

@md.fahad742
hello Fahad,
pls share ur code using coding blocks ide

https://ide.codingblocks.com/s/188625

have a look at my code what’s going wrong

@md.fahad742
hello fahad ,
ur logic for query and update of bit is not correct.
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.

checkout getmax (query) and add(update) function from here -> https://ide.codingblocks.com/s/188640