#K80282. Minimum Machines Required

    ID: 35496 Type: Default 1000ms 256MiB

Minimum Machines Required

Minimum Machines Required

You are given a set of tasks, each with a start time and an end time. Two tasks overlap if one task starts before the other one ends. Your job is to determine the minimum number of machines needed so that all tasks can be processed without any overlapping tasks being assigned to the same machine.

More formally, if the tasks are represented by intervals \( [s, e) \), you must compute the maximum number of intervals overlapping at any time. This number is equal to the minimum number of machines required.

For example, if you are given three tasks with intervals (1, 4), (2, 5), and (3, 6), all three tasks overlap at some point, so you will need 3 machines.

inputFormat

The input begins with a single integer \( n \) representing 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 representing the minimum number of machines required to process all tasks without any overlap on the same machine.

## sample
3
1 4
2 5
3 6
3