#Lutece1802. The Night of Xiaomai
The Night of Xiaomai
Migrated from Lutece 1802 The Night of Xiaomai
All parts of this problem, including description, images, samples, data and checker, might be broken. If you find bugs in this problem, please contact the admins.
Description
The brother is on business, so Xiaomai will have a fantastic night, which makes her do anything she wants. There are n game(s) of kinds to be played. In every game, she can get points on happiness, but it takes points on time and points to have the room dirty. If the brother comes at the time of , she is still playing the game or the points are over y on the room dirty. As a result, she will be punished. Therefore, the cute Xiaomai hope that you can help her make a perfect plan, which can get the most happiness points without the brother’s punishment.
Input
The first line contains three integers , and (, ).
Each of the following lines contains three integers , and ().
Output
In the first line print a single integer denoting the happy points Xiaomai gets.
Samples
5 5 5
10 6 0
2 4 4
3 4 4
0 0 0
0 0 0
3