CSES Robot Path

Here is the problem: CSES - Robot Path

How do I proceed further on this problem?

My progress:

The problem has binary search structure. Thus, we can use it.

But how do I proceed further? Any hints/help is appreciated.