#P14811. [CCPC 2024 哈尔滨站] 农场经营
[CCPC 2024 哈尔滨站] 农场经营
Description
You have given up programming and moved to the Sanjiang Plain to start farming. During your time working in the fields, you have adopted a regular daily schedule, and now you work units of time each day. It is now harvest season, and you need to harvest and process types of crops. For crop type , processing it for one unit of time will yield a profit of . To make your daily work less monotonous, for each crop type , the time spent processing it each day can range between inclusive as an integer.
At some day, the weather forecast says that there will be a heavy rain tomorrow and you can't work, so you need to adjust your schedule to quickly gather your crops today. Specifically, you can choose at most one type of crop and remove its daily time range restriction, allowing the time spent processing this crop to be any integer in the range . The time ranges for all other crops remain unchanged. You have to work units of time as well.
You want to determine the maximum profit you can earn today.
Input Format
The first line contains two integers and (, ), representing the number of crop types and the length of the workday in units of time, respectively.
The next lines each contain three integers , , and (, ), indicating the profits and time constraints of the crops.
It is guaranteed that .
Output Format
Output a single integer representing the maximum profit you can earn today.
5 17
2 3 4
6 1 5
8 2 4
4 3 3
7 5 5
109
京公网安备 11011102002149号