#P1910. Spy Selection
Spy Selection
Spy Selection
In the famous saying, "Know yourself and know your enemy, and you can fight a hundred battles without disaster." The commander of country L wants to send spies into country I, and you have been tasked with selecting the candidates.
You are given \(N\) candidates. Each candidate has three attributes:
- \(A\): The amount of information they can gather.
- \(B\): Their poor disguise capability (a higher value means worse disguise).
- \(C\): Their salary requirement.
You are also given two constraints:
- The enemy's espionage detection limit \(M\), meaning that the sum of \(B\) for all selected candidates must be \(\le M\).
- The total money available \(X\), so the sum of \(C\) for all selected candidates must be \(\le X\).
Your task is to select a subset of candidates such that both constraints are satisfied and the total amount of gathered information \(\sum A\) is maximized.
inputFormat
The first line contains three integers: \(N\), \(M\) and \(X\) where \(N\) is the number of candidates, \(M\) is the maximum allowed sum of \(B\) values, and \(X\) is the available budget.
The next \(N\) lines each contain three integers \(A\), \(B\), and \(C\) representing the candidate's information value, disguise penalty, and salary requirement respectively.
outputFormat
Output a single integer which is the maximum amount of information that can be gathered under the given constraints.
sample
3 5 10
5 2 3
7 3 5
4 1 2
12