MetaOA #25
Buses in a Bustling Town
估计简单可在线判题
考点(AI 标注)字符串模拟/实现
Given the day's bus departure times and the current time, find how many minutes ago the most recent bus that has already departed left. A bus scheduled exactly at the current time has not departed yet; it must be strictly earlier than the current time. If there is none, output −1; the previous day is not considered.
输入格式
This site's input: the first line contains n (0..100000), followed by n lines of HH:MM times, and the last line is the current time. Hours are 00..23 and minutes are 00..59, and all times are on the same day; the timetable may be unsorted and may contain duplicates.
输出格式
Output the number of minutes, or −1.
样例 1
输入:
3
12:30
14:00
19:55
14:30
输出:
30
样例 2
输入:
3
00:00
14:00
19:55
00:00
输出:
-1
样例 3
输入:
3
12:30
14:00
19:55
14:00
输出:
90
样例说明
Example 1: the last bus that departed left at 14:00, which is 30 minutes before 14:30.
Example 2: the 00:00 bus is exactly at the current time and has not departed yet, so the output is −1.
Example 3: the 14:00 bus has not departed yet; the previous one is 12:30, 90 minutes earlier.