Given t1, t2, dist, determine the time costs before GF see the gift of two plans:
Chef waits for GF, and then goes
home together.
Chef returns home first, and goes back to GF.
EXPLANATION:
For the first plan, the answer should be (t2 - t1) + dist.
For the second one, it will be a little complicated. We need to discuss in 2 cases:
If dist + dist <= t2 - t1, then Chef can return the bus station before GF arrived. Therefore, the answer should be t2 - t1.
If t2 - t1 < dist + dist, then they will meet at the trip of going back. Therefore, the answer should be the middle point of the trip (imagine that the three parts as a whole): (t2 - t1 + dist * 2) / 2.
AUTHOR’S AND TESTER’S SOLUTIONS:
Author’s solution can be found here.
Tester’s solution can be found here.
Chef and his gf can meet at the middle point of the trip if and only if the difference in times between time1 and time2 = dist. Since this hasn’t been mentioned in the question explicitly, we can’t assume this thing. So can u plz explain once again ?