Skip to content

Lists : Sample Problem 1

Sibsankar Majumder edited this page May 30, 2020 · 1 revision

The Gocargo carriers want to improvise their financial targets this annual year. They have planned to increase the container's profit value. Given the profit values of the cargos and the capacity of the container, determine the maximum profit value that the container can yeild.

Input format: The first line of input consists of a comma separated list of integers, profit values of cargos. The second line of input consists of an integer, which corresponds to the container’s capacity.

Assume: All profit values are unique.

Output format: Output is an integer, the maximum profit value of the container.

Sample Input 1:

12,4,15,30,40

3

Sample Output 1:

85

Explanation for the sample: The capacity of the container is 3. The top 3 profitable cargos are 40, 30 and 15. Therefore, total profit = 85.

Reference: https://www.chegg.com/homework-help/questions-and-answers/gocargo-carriers-want-improvise-financial-targets-annual-year-planned-increase-container-s-q26104318

Clone this wiki locally