luogu#P8903. [USACO22DEC] Bribing Friends G
[USACO22DEC] Bribing Friends G
Problem Description
Bessie wants to watch the documentary: Cow Genomics, but she does not want to go alone. Unfortunately, her friends are not enthusiastic enough to go with her. So Bessie needs to bribe her friends to accompany her to the movie theater. She has two tools in her bribery arsenal: Moonies and ice cream cones.
Bessie has friends. However, not all friends are created equal. Friend has popularity , and Bessie wants to maximize the sum of popularities of the friends who go with her. Friend will go with Bessie only if Bessie gives her Moonies. If Bessie gives her ice cream cones, then the friend can also give Bessie a discount of Moony. Bessie can obtain any integer number of discounts from a friend, as long as these discounts do not make the friend give Moonies back to her.
Bessie has Moonies and ice cream cones available (). Please help her find the maximum possible total popularity she can achieve if she spends her Moonies and ice cream cones in the best way.
Input Format
The first line contains three integers , , and , representing the number of friends Bessie has, the number of Moonies, and the number of ice cream cones.
The next lines each contain three integers , , and , representing the popularity (), the number of Moonies needed to bribe friend to accompany Bessie (), and the number of ice cream cones needed to get a discount of Moony from friend ().
Output Format
Output the maximum total popularity of the friends who accompany Bessie, assuming she spends her Moonies and ice cream cones in the best way.
3 10 8
5 5 4
6 7 3
10 6 3
15
Hint
Explanation for Sample 1
Bessie can give Moonies and ice cream cones to cow , and give Moonies and ice cream cones to cow . Then cows and can accompany her, obtaining popularity .
Test Point Properties
- Test points satisfy and .
- Test points satisfy .
- Test points satisfy .
- Test points satisfy .
- Test points have no additional constraints.
Translated by ChatGPT 5