#C6184. Next Reminder Scheduler
Next Reminder Scheduler
Next Reminder Scheduler
You are given the current time and a list of weekly reminder time slots. Each time is in the format Day HH:MM, where Day is one of Monday, Tuesday, Wednesday, Thursday, Friday, Saturday, or Sunday, and HH:MM is a 24-hour time format.
Your task is to determine the next available reminder time slot that occurs strictly after the current time. If there are no available slots later in the week, the schedule wraps around to the beginning of the week. The time comparison is based on the total minutes passed since the start of the week. In other words, if we let \(T = \text{day_index} \times 1440 + \text{hour} \times 60 + \text{minute}\) (where Monday = 0, Tuesday = 1, …, Sunday = 6), find the smallest time \(t\) from the list such that \(t > T\). If no such \(t\) exists, return the first time slot of the next week.
For example, given the current time "Thursday 16:35" and list of slots ["Monday 14:00", "Wednesday 09:00", "Thursday 18:00", "Saturday 12:00", "Sunday 16:45"], the next reminder is "Thursday 18:00".
inputFormat
The input is given via stdin
and consists of:
- A line containing the current time as a string in the format Day HH:MM.
- A line containing an integer n representing the number of available time slots.
- n subsequent lines, each containing a reminder time slot in the format Day HH:MM.
outputFormat
Output the next available reminder time slot (as a string in the format Day HH:MM) to stdout
.
Thursday 16:35
5
Monday 14:00
Wednesday 09:00
Thursday 18:00
Saturday 12:00
Sunday 16:45
Thursday 18:00