#K72387. Longest Consecutive Timestamps

    ID: 33742 Type: Default 1000ms 256MiB

Longest Consecutive Timestamps

Longest Consecutive Timestamps

Given a list of timestamps in the format HH:MM, find the length of the longest sequence of consecutive times when the timestamps are converted to minutes. Two timestamps are consecutive if the minute value of one is exactly one more than the minute value of the previous one after sorting all timestamps in non‐decreasing order.

For example, consider the timestamps "10:00", "09:58", "09:59", "10:01", "10:02". When converted to minutes and sorted, they form a consecutive sequence: 598, 599, 600, 601, 602. Thus, the length of the longest sequence is 5.

Your task is to write a program that reads the number of timestamps and the list of timestamps from standard input (stdin) and outputs the length of the longest consecutive sequence to standard output (stdout).

Note: Even if the timestamps are not in order, you must sort them before checking for consecutiveness. Duplicate timestamps are allowed and should be counted as one in terms of forming a sequence (i.e. they do not extend a consecutive sequence).

inputFormat

The first line of input contains an integer n representing the number of timestamps.

The next n lines each contain a timestamp in the format HH:MM.

outputFormat

Output a single integer representing the length of the longest sequence of consecutive timestamps (in minutes) after sorting.

## sample
5
10:00
09:58
09:59
10:01
10:02
5

</p>