#P1509. 找啊找啊找朋友
找啊找啊找朋友
Problem Description
There are tasks. Completing task requires units of budget, units of points, and units of time.
You have units of budget and units of points. Select a subset of tasks such that their total budget cost does not exceed and their total point cost does not exceed .
Your primary objective is to maximize the number of completed tasks. Among all selections containing the maximum possible number of tasks, minimize the total time required. Output this minimum total time. If no task can be completed, output .
Input Format
The first line contains an integer , representing the number of tasks.
Each of the next lines contains three integers , representing the budget cost, point cost, and time required to complete task .
The last line contains two integers , representing the available budget and points.
Output Format
Output one integer: the minimum total time among all selections containing the maximum possible number of tasks.
4
1 2 5
2 1 6
2 2 2
2 2 3
5 5
13
Hint
For of the test cases, .
For all test cases, , , and .