#C6019. Maximum Points in Limited Time
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:
- The first line contains two integers \(n\) and \(T\), where \(n\) is the number of problems and \(T\) is the total available time.
- The second line contains \(n\) space-separated integers representing the time required for each problem \(t_1, t_2, \dots, t_n\).
- 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.
## sample4 5
1 2 3 2
10 20 30 25
55
</p>