#P1509. MM Selection Optimization

    ID: 14795 Type: Default 1000ms 256MiB

MM Selection Optimization

MM Selection Optimization

Sqybi has selected \(n\) potential candidates (MMs), numbered from \(1\) to \(n\). Inviting the \(i\)-th candidate for a meal costs \(rmb[i]\) money units, and trying to win her over as a girlfriend costs \(rp[i]\) reputation points. In addition, each candidate requires \(time[i]\) units of time to be processed. Sqybi has a total of \(m\) money units and \(r\) reputation points. Note that at any moment, Sqybi can only work on one candidate.

The objective is to select a subset of candidates such that:

  1. The number of selected candidates is maximized, subject to the constraints \(\sum rmb[i] \le m\) and \(\sum rp[i] \le r\).
  2. Among all selections with the maximum number of candidates, the total time \(\sum time[i]\) is minimized.

Output the minimum total time required to achieve the maximum number of candidates.

inputFormat

The input consists of four lines:

  1. The first line contains three integers: \(n\) (the number of candidates), \(m\) (the total money available), and \(r\) (the total reputation available).
  2. The second line contains \(n\) space-separated integers representing the array \(rmb\): the cost in money for each candidate.
  3. The third line contains \(n\) space-separated integers representing the array \(rp\): the reputation cost for each candidate.
  4. The fourth line contains \(n\) space-separated integers representing the array \(time\): the time required for each candidate.

outputFormat

Output a single integer on a line: the minimum total time required to select the maximum number of candidates under the constraints. If no candidate can be selected, output 0.

sample

3 10 10
5 6 3
3 5 2
5 10 2
7