#K95992. Calculate Working Time

    ID: 38986 Type: Default 1000ms 256MiB

Calculate Working Time

Calculate Working Time

In this problem, you are given two times in 24-hour format representing the start and end of an employee's working shift. An employee can work either during the morning shift from 9:00 AM to 5:00 PM or the evening shift from 6:00 PM to 2:00 AM (the next day). In both cases, the effective working duration is exactly 8 hours.

Your task is to compute the total working time between the given start and end times and output it in the format X hours Y minutes.

Note: If the end time is earlier than or equal to the start time in terms of minutes from midnight, it implies that the work period extends into the next day.

The calculation should follow the formula:

\( \text{Total Minutes} = \text{End Minutes} - \text{Start Minutes} \) (adding 1440 minutes if necessary), then
\( X = \lfloor \frac{\text{Total Minutes}}{60} \rfloor \) and \( Y = \text{Total Minutes} \mod 60 \).

inputFormat

The input consists of a single line containing four integers separated by spaces:

  • start_h and start_m representing the start time in hours and minutes.
  • end_h and end_m representing the end time in hours and minutes.

Times are given in 24-hour format.

outputFormat

Output a single line displaying the total working time in the format:

X hours Y minutes

## sample
9 0 17 0
8 hours 0 minutes