#K60177. Maximum Simultaneous Tourists

    ID: 31029 Type: Default 1000ms 256MiB

Maximum Simultaneous Tourists

Maximum Simultaneous Tourists

Given a series of tourist visit times denoted as arrival and departure times, determine the maximum number of tourists that are present in the forest at any point in time. Each tourist is represented by an interval [a, b] where a is the arrival time and b is the departure time. In particular, if a tourist departs at time t and another arrives exactly at time t, the arriving tourist is considered present before the departure. The problem can be formalized as finding the maximum value of f(t) over time, where f(t) = \# \{ i : a_i \le t < b_i \}. Use \(\LaTeX\) formatting for mathematical formulas when necessary.

inputFormat

The first line contains an integer (n) representing the number of tourist intervals. Each of the following (n) lines contains two space-separated integers indicating the arrival time and the departure time of a tourist.

outputFormat

Output a single integer representing the maximum number of tourists present at the same time.## sample

3
1 5
2 8
4 6
3