cswork / OA打开练习工作台

UberOA #20

Bus Time

估计简单可在线判题

考点(AI 标注)字符串模拟/实现

Given the day's departure times and the current time, find how many minutes have passed since the most recent bus that has already departed. A bus departing exactly at the current time does not count as departed; if no bus has departed yet that day, return −1, without wrapping around to the previous day.

This site's standard input/output is stated explicitly.

输入格式

The first line contains n, followed by n lines of departure times in HH:MM format, and the last line contains the current time. This site uses 0≤n≤100000 and times in 00:00..23:59. The list is given in non-decreasing time order and may contain duplicates.

输出格式

Output one integer answer.

样例 1

输入:

3
12:30
14:00
19:55
14:30

输出:

30

样例 2

输入:

2
12:30
14:00
14:00

输出:

90

样例 3

输入:

1
00:00
00:00

输出:

-1

样例说明

Example 1: the most recent departure was at 14:00, 30 minutes ago. Example 2: the 14:00 bus does not count as departed yet, so only 12:30 counts, 90 minutes ago. Example 3: the bus at exactly 00:00 does not count as departed, and there is no earlier bus that day, so the output is −1.