Quantcast
Channel: CodeChef Discuss - latest questions
Viewing all articles
Browse latest Browse all 40121

GERALD04 - Editorial

$
0
0

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.


Viewing all articles
Browse latest Browse all 40121

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>