How to solve the following problem

https://cses.fi/problemset/task/1164
I am using binary search but not able to solve

You can check mine solution i have solved it using map .
here is my code code
I hope you will find it useful :smile: :smile:

thnx

can you plz explain your code what you actually want to do.