Question: Problem 3: Scuba Diver (12 points) A scuba diver uses a special equipment for diving. He has a cylinder with two containers: one with oxygen

 Problem 3: Scuba Diver (12 points) A scuba diver uses a

Problem 3: Scuba Diver (12 points) A scuba diver uses a special equipment for diving. He has a cylinder with two containers: one with oxygen and the other with nitrogen. Depending on the time he wants to stay under water and the depth of diving the scuba diver needs various amount of oxygen and nitrogen. The scuba diver has at his disposal a certain number of cylinders. Each cylinder can be descnibed by its weight and the volume of gas it contains. In order to complete his task the scuba diver needs specific amounts of oxygen and nitrogen. Theoretically, the diver can take as many cylinders as he wantseeds. Use dynamic programming to find the minimal total weight of cylinders he has to take to complete the task and which those cylinders are. In case of several acceptable solutions, printing just one of them is enough. Example The scuba diver has at his disposal 5 cylinders described below. Each description consists of: volume of oxygen, volume of nitrogen (both values are given in liters) and weight of the cylinder (given in decagrams) 3 36 120 10 25 129 1 45 130 4 20 11 If the scuba diver needs 5 liters of oxygen and 6D liters of nitrogen then he has to take two cylinders of total weight 249 (tor example the first and the second ones or the fourth and the fifth ones). Input The number of test cases cis in the first ine ot input, then ctest cases follow separated by an empty line. In the tirst line of a test case there are two integers t, a separated by a single space, 1 s t 21 and lS a 79. They denote volumes of oxygen and nitrogen respectively, needed to complete the task. The second line contains one intege n 1000, which is the number of accessible cylinders. The follow- ing n lines contain descriptions of cylinders; -h line contains three integers t, a,u, separated by single spaces.(1 t? 21. 1 a; 79. I w, 800). These are respectively: volume of oxygen and nitrogen in the i-th cylinder and the weight of this cylinder Output On the tirst line will be printed the total weight cylinders in order. and on the next line separated by spaces the index of the Sample input 5 60 3 36 120 10 25 129 1 45 130 4 20 119 Sample output

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!