#P2079. 烛光晚餐
烛光晚餐
Description
Xiaohong says: “Xiaoming, you order.” Xiaoming sees dishes on the menu, with each dish priced at . Xiaoming’s preference score for each dish is , and Xiaohong’s preference score for each dish is . (Preference scores may be negative.) (Xiaoming: Based on what I know about her, the data I give you won’t be wrong.)
Xiaoming brought yuan, and the total price of the dishes he orders cannot exceed . (Xiaoming: Of course I’m paying, it makes me look generous.)
Xiaoming wants to make Xiaohong happy, so he wants her total preference score to be as large as possible. Of course, he also needs to consider his own feelings: the total preference score of all ordered dishes for him must be greater than or equal to . (Xiaoming: If I don’t eat well, she’ll feel bad when she sees it.)
Please help Xiaoming write a program to compute the maximum possible total preference score of Xiaohong under the condition that his own total preference score is greater than or equal to . (Xiaoming: Your program must be reliable. I need to make a good impression on her.)
Input Format
The first line contains two positive integers , .
Then follow lines, each containing three space-separated numbers: a positive integer , and integers , .
Output Format
One line with one integer: the maximum possible total preference score of Xiaohong under the condition that Xiaoming’s total preference score is greater than or equal to . If this maximum is less than , output .
4 10
5 -1 3
2 2 2
11 -5 100
3 -3 10
5
Hint
For of the testdata, , .
For of the testdata, .
For of the testdata, , , , .
Translated by ChatGPT 5
京公网安备 11011102002149号