#K43517. Minimum Servers Scheduling
Minimum Servers Scheduling
Minimum Servers Scheduling
You are given a list of tasks where each task is described by a start time and an end time. Each task must be executed on a server and tasks running concurrently must be processed by separate servers. Your goal is to determine the minimum number of servers required so that all tasks can be scheduled without any overlap on the same server.
More formally, given a list of tasks \( (s_i, e_i) \) where \( s_i < e_i \) for every task, compute the minimum number of servers required such that no two tasks which overlap in time are scheduled on the same server. The answer is the maximum number of tasks that overlap at any time. Recall that two tasks \( (s_i, e_i) \) and \( (s_j, e_j) \) do not overlap if \( e_i \leq s_j \) or \( e_j \leq s_i \).
Input/Output Specification details are provided below.
inputFormat
The input is read from standard input (stdin). The first line contains a single integer ( n ) representing the number of tasks. The following ( n ) lines each contain two space-separated integers ( s ) and ( t ), indicating the start and end times of the task respectively. If ( n = 0 ), there are no tasks, and the output should be 0.
outputFormat
Output a single integer to standard output (stdout), which is the minimum number of servers required to schedule all tasks without overlap.## sample
3
1 4
2 5
3 6
3