Chairs
InterviewTime limit1sMemory limit512 MB
Given each person's entry and exit time on a single day, find the maximum number of people inside the library at any moment, counting entry and exit seconds as inside.
- Level
Easy3 of 10
- Topics
- Sorting, Intervals, Implementation, Simulation
- Solved
- No attempts yet
Problem
To predict how many chairs the library of the Aglargond School of Magic needs, Ataranon, the school principal, ordered that the exact times each person enters and leaves the library be written down. Write a program that finds the greatest number of people inside the library at one moment, given that N people in total entered the library. Every person entered and left the library during one day. The second a person enters or leaves the library also counts as a second that person spent inside.
Input
The first line of input contains N (0 ≤ N ≤ 1000). The next N lines contain the hour, minute, and second of entry and the hour, minute, and second of exit, separated by one space. Times are given in the format HH:MM:SS, where HH is hours (00 ≤ HH ≤ 23), MM is minutes (00 ≤ MM ≤ 59), and SS is seconds (00 ≤ SS ≤ 59).
Output
Print exactly one line containing only the greatest number of people inside the library at one moment.
Hint
During the interval between 11:15:17 and 13:00:24 there were three people inside the library.