GERALD04 - Editorial

PROBLEM LINK:

Practice
Contest

Author: Gerald Agapov
Tester: Tasnim Imran Sunny
Editorialist: Jingbo Shang

DIFFICULTY:

Cakewalk

PREREQUISITES:

Programming

PROBLEM:

GF — (t2 - t1) — Chef — dist — Home

Given t1, t2, dist, determine the time costs before GF see the gift of two plans:

  1. Chef waits for GF, and then goes
    home together.
  2. 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:

  1. If dist + dist <= t2 - t1, then Chef can return the bus station before GF arrived. Therefore, the answer should be t2 - t1.
  2. 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.

3 Likes

Solutions are redirecting to this page itself!

they will be updated soon I guess. You can check solutions of people who got AC by going over to the contest problem link

solutions are uploaded…check out

for the second type of plan you have written that there are 3 cases but you have written only 2

There are just 2 cases.

There are 3 types of people: those who can count and those who can’t :smiley:

Why was my code getting WA? Wasn’t it basically the same thing?
http://www.codechef.com/viewsolution/3122236

Please Explain “the answer should be the middle point of the trip” in the second case?

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 ?

why is it necessary that chef and girlfriend meet at the middle point?

https://www.codechef.com/viewsolution/14258608

why is it giving me a WA?

I am not able to understand how will they meet at the middle only…anyone please explain