Drone Packing
Time limit2sMemory limit512 MB
Choose items to load onto two drones with separate weight capacities so total value is maximized, with no item split or shared.
- Level
Medium7 of 10
- Topics
- Dynamic programming, Greedy, Sorting
- Solved
- No attempts yet
Problem
The North Pole delivery centre is retiring the sleigh and moving to drones. The first trial run has only two drones, and each drone has a limit on the weight it can carry.
You are given a list of candidate presents. Every present has a weight and a value, and the value is an integer in thousands of dollars. Choose presents and split them between the two drones so that the total value carried is as large as possible. A present cannot be cut apart, and one present cannot be shared by the two drones. Leaving presents behind is allowed.
The weights loaded onto a drone must sum to at most that drone's limit. Find the largest total value you can achieve.
Input
The input holds several problems. The first line has the number of problems ().
Three lines follow for each problem. The first line has the number of candidate presents () and the carrying limits of the two drones and (). The second line has the weights (). The third line has the values (). Numbers on a line are separated by single spaces, with no leading or trailing spaces.
Output
Print one line for each problem. The line is Problem , the problem number counting from 1, : , and the largest total value the two drones can carry.
If the answer to the first problem is 22, print Problem 1: 22.