Restaurant customers
Time: 1 s · Memory: 256 MB
- Sorting
Statement
customers visited a restaurant: customer arrived at time and left at time . A customer who leaves at time is not counted together with one who arrives at that same time. What was the maximum number of customers in the restaurant at the same time?
Input format
The first line contains (). The next lines contain and ().
Output format
A single number — the maximum number of customers at the same time.
Examples
Input
3 5 8 2 4 3 9
Output
2
Note
Sweep line: every customer gives two events — and . Sort the events by time; on equal times a departure () comes before an arrival (). Adding the events in order gives the current number of people in the restaurant — its maximum is the answer.
This is . Checking every moment of time does not work with times up to . In the example there are people from to .
Source: CSES, problem 1619.
