Here’s my take on today’s problem (27 July Medium Quant)
Here is one way to look at it. Please let me know if I missed something.