Company: Hackerearth_6april
Difficulty: medium
Modified Knapsack You will be given N elements, each consisting of three numbers. They are type, weight and value. You will also be given a value K. You have to select few [unclear] elements such that the following property holds: You can [unclear] pick more than one element of the same type. The total weight of the selected elements have to be less than or equal to K. The total value of the selected elements should be as large as possible. You have to output the maximized total value of the selected elements. Input Format: The first line of will contain an integers N. Each of the next N lines will contain three integers, representing the type, weight and value of an element. The last line will [unclear] an integer K. Output Format: For each case, print the desired result. Constraints: 1 ≤ N, type, weight, value, k ≤ 5 * 10 3 Sample Input 1 6 1 3 13 5 1 10 2 2 1 1 4 9 4 5 11 1 5 9 6 Sample Output 1 24 Explanation By taking first three elements would give maximum value of 24. Note: Your