Rig Placement
InterviewTime limit1sMemory limit128 MB
Given n oil fields, a per-field investment cap m, and a total budget B, pick an investment amount for each field so total oil is maximized.
- Level
Medium5 of 10
- Topics
- Dynamic programming, Array, Implementation, Brute force
- Solved
- No attempts yet
Problem
Suppose we have already found where the oil is and, beyond that, we also know how much oil there is at each location. The next question is where to place the oil rigs so that, after a rig explodes, we can spill (extract) as much oil as possible. This turns out to be not completely trivial.
We model the problem as follows. There are oil fields we may want to exploit, where . For each oil field we can decide how much money to invest, in increments of one million dollars, from up to (here is the maximum investment allowed per oil field). For each oil field () and each investment amount , a table entry gives the (non-negative real) amount of oil you obtain. The table entries are non-decreasing in (spending more money yields at least as much oil as before), but are otherwise arbitrary. The total budget available for rigs is an integer with (again in increments of one million dollars). Compute the maximum total amount of oil you can extract within your budget.
Input
The first line contains the number of data sets. It is followed by the data sets, each of the following form.
The first line of a data set contains three integers , , and : the number of oil fields, the maximum investment per oil field, and the total budget.
This is followed by lines, each containing non-negative floating-point numbers. On the -th line, the -th number () is the amount of oil you would extract from oil field if you invested million dollars in it.
Output
For each data set, print Data Set x: on a line by itself, where is its number. On the next line, print the maximum total amount of oil you can extract under the given constraints, rounded to two decimal places. Separate two neighboring data sets with a single blank line.