Bribing Friends

아직 제출이 없습니다시간 제한2초메모리 제한1024 MB

문제

Bessie wants to watch Bovine Genomics: The Documentary, but she doesn’t want to go alone. Unfortunately, her friends aren’t enthusiastic enough to go with her! Therefore, Bessie needs to bribe her friends to accompany her to the movie theater. She has two tools in her bribery arsenal: mooney and ice cream cones.

Bessie has NN (1N20001 \le N \le 2000) friends. However, not all friends are created equal! Friend ii has a popularity score of P_iP\_i (1P_i20001 \le P\_i \le 2000), and Bessie wants to maximize the sum of the popularity scores of the friends accompanying her. Friend ii is only willing to accompany Bessie if she gives them C_iC\_i (1C_i20001 \le C\_i \le 2000) moonies. They will also offer her a discount of 11 mooney if she gives them X_iX\_i (1X_i20001 \le X\_i \le 2000) ice cream cones. Bessie can get as many whole-number discounts as she wants from a friend, as long as the discounts don’t cause the friend to give her mooney.

Bessie has AA moonies and BB ice cream cones at her disposal (0A,B20000 \le A, B \le 2000). Help her determine the maximum sum of the popularity scores she can achieve if she spends her mooney and ice cream cones optimally!

입력

Line 11 contains three numbers NN, AA, and BB, representing the number of friends, the amount of mooney, and the number of ice cream cones Bessie has respectively.

Each of the next NN lines contains three numbers, P_iP\_i, C_iC\_i, and X_iX\_i, representing popularity (P_iP\_i), mooney needed to bribe friend ii to accompany Bessie (C_iC\_i), and ice cream cones needed to receive a discount of 11 mooney from friend ii (X_iX\_i).

출력

Output the maximum sum of the popularity scores of the friends accompanying Bessie, assuming she spends her moonie and ice cream cones optimally.

힌트

Bessie can give 44 moonies and 44 ice cream cones to cow 11, and 66 moonies and 33 ice cream cones to cow 33, in order to get cows 11 and 33 to accompany her for a total popularity of 5+10=155 + 10 = 15.