RACE400M - Editorial

PROBLEM LINK:

Practice
Contest: Division 1
Contest: Division 2
Contest: Division 3
Contest: Division 4

Author: notsoloud
Testers: iceknight1093, yash_daga
Editorialist: iceknight1093

DIFFICULTY:

TBD

PREREQUISITES:

None

PROBLEM:

Given the times taken by Alice, Bob, and Charlie to run a 400\ M race, (A, B, C respectively), who had the highest average speed?

EXPLANATION:

Using the formula \text{distance} = \text{speed} \times \text{time}, we can see that the highest average speed corresponds to the lowest time taken.

So, find who out of Alice/Bob/Charlie took the lowest time; that person also has the highest average speed.
This can be implemented with a couple of if conditions.

TIME COMPLEXITY:

\mathcal{O}(1) per testcase.

CODE:

Editorialist's code (Python)
for _ in range(int(input())):
    x, y, z = map(int, input().split())
    if x == min(x, y, z): print('Alice')
    if y == min(x, y, z): print('Bob')
    if z == min(x, y, z): print('Charlie')