luogu#P1417. 烹调方案
烹调方案
Background
Thanks to your help, Mars suffered only minimal damage. But gw was too lazy to rebuild his home, so he built a spaceship and headed toward the distant planet Earth. Halfway through the journey, gw realized a serious problem: he was hungry.
gw can still cook, so he took out stored food to fill his stomach. gw hopes to cook the most delicious food within time, but the way to calculate deliciousness is unusual, so the desperate gw is asking for your help.
Problem Description
There are ingredients. Each ingredient has three attributes, , , and . If ingredient is completed at time , you gain a deliciousness score of . Cooking ingredient takes time.
As everyone knows, gw is not very good at cooking, so you need to design a cooking plan to maximize the deliciousness score. All cooking must be finished within time .
Input Format
The first line contains two positive integers and , representing the time needed to reach Earth and the number of ingredients.
- The next line contains integers, .
- The next line contains integers, .
- The next line contains integers, .
Output Format
Output the maximum deliciousness score.
74 1
502
2
47
408
Hint
- Constraints:
- For of the testdata, .
- For of the testdata, .
- All numbers are less than .
- Source: adapted by tinylic.
Translated by ChatGPT 5