#C5231. Maximum Overlapping Tasks
Maximum Overlapping Tasks
Maximum Overlapping Tasks
You are given a series of tasks, each represented by a start time and an end time. Your goal is to determine the maximum number of tasks that overlap at any point in time. A task is considered active in the interval [s, e] (i.e. from time s up to time e). Formally, if we denote (\delta = +1) for a starting task and (\delta = -1) for an ending task, after sorting all events by time (with starting events processed before ending events in case of ties), the maximum overlap is defined as (\max_{1\le i \le m} \left( \sum_{j=1}^{i} \delta_j \right)), where (m) is the total number of events.
Read the input from STDIN, process the tasks, and output the result to STDOUT.
inputFormat
The first line contains an integer (n) denoting the number of tasks. Each of the following (n) lines contains two space-separated integers representing the start time and end time of a task.
outputFormat
Output a single integer that represents the maximum number of overlapping tasks at any given point in time.## sample
5
1 5
2 6
8 10
3 7
5 9
3