#C14350. Task Scheduling Optimization

    ID: 43990 Type: Default 1000ms 256MiB

Task Scheduling Optimization

Task Scheduling Optimization

You are given a list of tasks which need to be scheduled on a multi-core processor system. Each task is defined by three integers: the start time \(s\), the end time \(e\), and the core requirement \(c\). Multiple tasks may overlap in time. Your goal is to determine the maximum number of cores that are concurrently in use, i.e. the maximum sum of \(c\) for tasks overlapping at any point in time.

Note: A task is active in the time interval \([s, e)\). That is, if a task ends at time \(e\), it does not count as overlapping with a task that starts at \(e\).

For example, consider the tasks:

(1, 4, 2)
(2, 3, 1)
(3, 5, 2)

The maximum concurrent core usage is 4 since from time \(3\) to \(4\), the first and third tasks overlap, requiring \(2+2=4\) cores.

inputFormat

The first line of the input contains an integer \(n\) representing the number of tasks. This is followed by \(n\) lines, each containing three space-separated integers \(s\), \(e\), and \(c\) which represent the start time, end time, and core requirement of a task, respectively.

Input Format Example:

5
1 4 2
2 3 1
3 5 2
4 7 1
6 8 2

outputFormat

Output a single integer representing the maximum number of cores concurrently in use at any time during the execution of the tasks.

Output Example:

4
## sample
5
1 4 2
2 3 1
3 5 2
4 7 1
6 8 2
4