#P2889. [USACO07NOV] Milking Time S

    ID: 1936 Type: RemoteJudge 1000ms 125MiB Tried: 0 Accepted: 0 Difficulty: 5 Uploaded By: Tags>动态规划,dp2007USACO排序背包

[USACO07NOV] Milking Time S

题目背景

:::warning{open} This question uses the original question data, but there is a problem with the original question data relative to the question surface. The actual data for this question is 0≤Starti<endi≤N0 \le Start_i<end_i \le N . :::

题目描述

Bessie can produce milk in the next NN hours. For convenience, we number these NN hours 0…N−10 \dots N - 1.

Within these NN hours, FJ has MM intervals during which he can milk Bessie. The ii-th interval runs from StartiStart_i to EndiEnd_i and yields EffiEff_i gallons of milk.

After each milking, Bessie must rest for RR hours before FJ can start the next milking.

Now, FJ needs you to compute the maximum total milk Bessie can produce within these NN hours.

输入格式

The first line contains three integers, representing NN, MM, and RR.

Lines 2…M+12 \dots M+1: the (i+1)(i+1)-th line contains three integers StartiStart_i, EndiEnd_i, and EffiEff_i, describing one milking interval.

输出格式

Output a single integer on one line: the answer.

12 4 2
1 2 8
10 12 19
3 6 24
7 10 31
43

提示

Constraints

For all testdata, it is guaranteed that 1≤N≤1061 \le N \le 10^6, 1≤M≤1031 \le M \le 10^3, 0≤Starti<Endi≤N−10 \le Start_i < End_i \le N - 1, and 1≤Effi≤1061 \le Eff_i \le 10^6.

Translated by ChatGPT 5