Editorial for Mock CCC '23 Contest 1 J2 - Healthy Schedule


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.

Authors: Marshmellon, Tommy_Shan

For this problem, we want to calculate Tommy's total sleep time and check if the conditions meet the requirements for a healthy schedule. Since the input is given in the 24-hour clock system, Tommy's total sleep time is given by 24-S+W. This is because Tommy's sleep time before midnight is 24-S, and his sleep time after midnight is W.

To determine if the sleep schedule is healthy, we can simply check if the following inequalities are satisfied:

  • 20 \le S \le 23, which checks if the sleep time is in the healthy interval.
  • 6 \le W \le 9, which checks if the wakeup time is in the healthy interval.
  • 8 \le 24-S+W \le 10, which checks if the total sleep time is in the healthy interval.

Time Complexity: \mathcal{O}(1)


Comments

There are no comments at the moment.