#K5196. Maximizing Developer Productivity

    ID: 29203 Type: Default 1000ms 256MiB

Maximizing Developer Productivity

Maximizing Developer Productivity

You are given a list of developers, where each developer is available from day \(s\) to day \(e\) (inclusive) and has a productivity score \(p\). The project lasts for \(d\) days. Each day, you need to choose one available developer who has the maximum productivity score among those available on that day. Your task is to calculate the maximum total productivity that can be achieved over the \(d\) days.

The overall productivity is defined as:

[ \text{Total Productivity} = \sum_{i=1}^{d} \max_{\substack{\text{developer } j \text{ such that}\ s_j \le i \le e_j}} p_j ]

If there is no developer available on a day, consider the productivity for that day to be 0.

inputFormat

The input is given from standard input in the following format:

n d
s1 e1 p1
s2 e2 p2
... 
sn en pn

Where:

  • \(n\) is the number of developers.
  • \(d\) is the number of days the project lasts.
  • Each of the next \(n\) lines contains three integers \(s, e, p\) representing the start day, end day, and productivity score of a developer.

outputFormat

Output to standard output a single integer: the maximum total productivity that can be achieved over the \(d\) days.

## sample
3 5
1 3 5
2 5 8
4 5 10
41