CF 1714A - Everyone Loves to Sleep
Vlad, like everyone else, loves to sleep very much.
Every day Vlad has to do n things, each at a certain time. For each of these things, he has an alarm clock set, the i-th of them is triggered on hi hours mi minutes every day (0≤hi<24,0≤mi<60). Vlad uses the 24-hour time format, so after h=12,m=59 comes h=13,m=0 and after h=23,m=59 comes h=0,m=0.
This time Vlad went to bed at H hours M minutes (0≤H<24,0≤M<60) and asks you to answer: how much he will be able to sleep until the next alarm clock.
If any alarm clock rings at the time when he went to bed, then he will sleep for a period of time of length 0.
-------------------------
弗拉德和其他人一样,非常喜欢睡觉。
弗拉德每天必须在特定的时间做 n 件事。 对于每件事,他都设置了一个闹钟,其中第 i 个闹钟在每天 hi 小时 mi 分钟触发(0≤hi<24,0≤mi<60)。 Vlad 使用 24 小时时间格式,因此在 h=12,m=59 之后为 h=13,m=0,在 h=23,m=59 之后为 h=0,m=0。
这次Vlad在H小时M分钟(0≤H<24,0≤M<60)上床睡觉,并要求你回答:直到下一个闹钟他还能睡多久。
如果他上床睡觉的时候有闹钟响了,那么他会睡一段长度为0的时间。
-----------------------------------------
把小时分钟换算成分钟数,如果闹钟的分钟数大于睡觉对应的分钟数,那么睡觉的时间就是闹钟的分钟数-睡觉对应的分钟数,如果小于,那么就是闹钟的分钟数+24*60-睡觉对应的分钟数即可,依次求最小值,然后将最小值换成成小时分钟即可;
下面是代码: