#C6019. Maximum Points in Limited Time

    ID: 49733 Type: Default 1000ms 256MiB

Maximum Points in Limited Time

Maximum Points in Limited Time

You are given n problems and a total time T hours. For each problem i, solving it requires ti hours and yields pi points. Your task is to choose a subset of these problems such that the total time spent does not exceed T, and the total points earned is maximized.

This problem is a typical instance of the knapsack problem. Formally, you need to maximize the total points \(\sum p_i\) subject to the constraint \(\sum t_i \leq T\).

inputFormat

The input is given via standard input (stdin) in the following format:

  1. The first line contains two integers \(n\) and \(T\), where \(n\) is the number of problems and \(T\) is the total available time.
  2. The second line contains \(n\) space-separated integers representing the time required for each problem \(t_1, t_2, \dots, t_n\).
  3. The third line contains \(n\) space-separated integers representing the points credited for each problem \(p_1, p_2, \dots, p_n\).

outputFormat

Output via standard output (stdout) a single integer, which is the maximum points that can be achieved under the given time constraint.

## sample
4 5
1 2 3 2
10 20 30 25
55

</p>