Editorial for ECOO '21 P1 - Many Messages


Remember to use this editorial only when stuck, and not to copy-paste code from it. Please be respectful to the problem author and editorialist.
Submitting an official solution before solving the problem yourself is a bannable offence.

For 30% of the points, since Larry always sends his message after Theodore last checks his phone, we can simply output Who knows....

For the rest of the points, note that we only have to consider three relevant times. Let M be the time when Larry starts his homework, and I be the interval. Let T be the time that Larry sent his message. We can simply check the 3 times M+I, M+2I and M+3I. If T is strictly greater than all of them, then we output Who knows..., otherwise we output the earliest time.

import sys

M = int(input())
I = int(input())
T = int(input())

for _ in range(3):
    M += I
    if T <= M:
        print(M)
        sys.exit()
print("Who knows...")

Comments

There are no comments at the moment.