Segment trees - MAX QUERY-I

Not getting correct output.

Problem: https://hack.codingblocks.com/contests/c/345/311

My Code: https://ide.codingblocks.com/s/74105

Hi tushar , explain your logic a little bit. Not able to get your logic by code.

Name is Het :yum: , anyways…

I have used multiset so the numbers are sorted.

Each node has elements of left+right child (line 25,26)

To print the query, when qs,qe complete covers s and e, i have returned num of element >= k for that node(line 39)
If partially covered then call left and right. (line 42-45)
else return 0 (line 31)
Finally, i have returned no of elements>=k from left & right , ie return left+right, (line 45)

sorry for that function naming :sweat_smile: