Unofficial CHEFRUN - Editorial

PROBLEM LINK

Practice
Contest

CONTEST CODE:

COOK94B

AUTHOR:

Yuri

DIFFICULTY:

Simple

PREREQUISITES:

Basics of Physics and coordinate system.

PROBLEM

Our aim is to find the time taken by Chef and Kefa and then compare those time.

EXPLANATION

Given for each test case:
X1 -Coordinate of Chef’s Restaurant
X2 -Coordinate of Kefa’s Restaurant
X3 -Coordinate of Secret Recipe

V1 -Chef’s running speed
V2 -Kefa’s running speed

Time=\frac{Distance}{Speed}

So in order to find time we need speed, which we already have and distance.
To calculate distance we use following formula:

Distance=|Difference of coordinates|

And finally the code snippet:

d1=abs(x1-x3);
d2=abs(x2-x3);
//remember t1 and t2 must be decimal numbers with up to 7 decimal places. 
//Also don't forget to type cast. 
t1=d1/v1;
t2=d2/v2;
//Now check the winner of race
if(t1>t2)
print("Kefa");
else if(t2>t1)
print("Chef");
//Don't forget draw case.
else
print("Draw")

Please add “Unofficial editorial” to the title. The title should NOT coincide with title of official editorials, so that anyone searching for official ones doesnt have to face inconvenience.

Also, the editorial can be improved, for case of draw. Read the official one to find out. Aside from that, minor syntax corrections and you are good to go. Thank you :slight_smile: