#K72507. Maximum Overlap of Tasks

    ID: 33768 Type: Default 1000ms 256MiB

Maximum Overlap of Tasks

Maximum Overlap of Tasks

You are given a list of tasks, each with a start time and an end time. Your task is to determine the maximum number of tasks that are active (overlapping) at the same time.

A task is represented as a pair of integers \(s\) and \(e\), where \(s\) is the start time and \(e\) is the end time. When two tasks share the same time value, a starting task is considered active before an ending task is deactivated.

For example, if tasks start at times 1 and 2 and end at times 4 and 5 respectively, there is an overlap of 2 tasks between times 2 and 4.

inputFormat

The first line contains an integer \(n\), the number of tasks. Each of the next \(n\) lines contains two space-separated integers \(s\) and \(e\), where \(s\) is the start time and \(e\) is the end time of a task.

outputFormat

Output a single integer denoting the maximum number of tasks that are active simultaneously.

## sample
5
1 4
2 5
9 12
5 9
5 12
3