Can anyone please help?

How to solve this? Any hints? Thinking in terms of binary search , but not able to do it

I think it could be solved using 4d-dp.