Payload for spacecraft
All submissions for this problem are available.
It is known that space exploration is very expensive. Human has never steeped foot to another planet other than moon. But with the help of “Autobots” they are designing an aircraft which would take them to the planet-“ Cybertron”- the planet of Autobots. But they are facing problem in payload which can be placed on aircraft. They can take only limited resources because they each resource posses some weight which adds up to the weight of permissible payload. However the resources are to be taken on the basis of cost and the permissible weight. So, they need to make a choice by selecting the product by its cost. They must also carry as much load as permitted by payload.
Given a set S of n resources such that each item i has a positive cost ci and a positive weight wi and we have to find the maximum benefit subset that does not exceed the given weight W. It is allowed to break resources into fractions arbitrary. The whole process is done so as to maximize the cost level of the total payload.
Total cost of the selected payload should be calculated.
First line contains the total number of resources. Second line of input contains the maximum permissible load (payload) of the spacecraft. Next line contains the weight of 1st item followed by the cost of that resource. Similarly, the next consecutive lines will contain the weight and cost depending upon the number of resources entered.
It should contain the total cost of the selected items. This is calculated by adding the products of the selected weights and the unit costs respectively of the resource. The output should be set to 6 digit of precision float type.
Input: 3 5 1 2 2 3 4 1 Output: 5.500000 Input: 4 8 3 8 4 7 2 4 2 3 Output: 17.250000
|Time Limit:||0.2 sec|
|Source Limit:||50000 Bytes|
|Languages:||C, JAVA, PYTH, PYTH 3.6, CS2, PAS fpc, PAS gpc, RUBY, PHP, GO, HASK, SCALA, D, PERL, FORT, WSPC, ADA, CAML, ICK, BF, ASM, CLPS, PRLG, ICON, SCM qobi, PIKE, ST, NICE, LUA, BASH, NEM, LISP sbcl, LISP clisp, SCM guile, JS, ERL, TCL, PERL6, TEXT, CLOJ, FS|
Fetching successful submissions