giving wrong for one test case
Kqueryo doubt code
@rohit_1906
Your logic is correct but there are few mistake in your code. I am pointing them
- your are filling array from 0 to (n-1) but building your tree from 1 to n. Change condition in line 32 to for(ll i=1;i<=n;i++)
- After print m, make ans=m for next iteration
- You have to find elements greater than k, not greater than equals to k. In line 22 you are finding lower_bound of k, which includes elements eqaul to k in final ans. So change lower_bound() in line 22 to (lower_bound(tree[node].begin(),tree[node].end(),k+1)