This page is still under construction.

Parts of this page are still being built. What you see may change.

Rig Placement

Interview

Time limit1sMemory limit128 MB

Summary
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 nn oil fields we may want to exploit, where 1≤n≤1001 \le n \le 100. For each oil field we can decide how much money to invest, in increments of one million dollars, from 00 up to mm (here mm is the maximum investment allowed per oil field). For each oil field ii (1≤i≤n1 \le i \le n) and each investment amount j∈{0,1,2,…,m}j \in \{0, 1, 2, \dots, m\}, a table entry a[i,j]a[i, j] gives the (non-negative real) amount of oil you obtain. The table entries are non-decreasing in jj (spending more money yields at least as much oil as before), but are otherwise arbitrary. The total budget available for rigs is an integer BB with 0≤B≤1000 \le B \le 100 (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 KK of data sets. It is followed by the KK data sets, each of the following form.

The first line of a data set contains three integers nn, mm, and BB: the number of oil fields, the maximum investment per oil field, and the total budget.

This is followed by nn lines, each containing m+1m + 1 non-negative floating-point numbers. On the ii-th line, the jj-th number (j=0,1,…,mj = 0, 1, \dots, m) is the amount of oil you would extract from oil field ii if you invested jj million dollars in it.

Output

For each data set, print Data Set x: on a line by itself, where xx 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.

Examples6

  1. Example 1

    Input
    1
    4 5 6
    0 2.3 2.3 2.3 2.3 2.3
    0 0 0 0 0 4.1
    0 1.0 2 3.0 4.0 5
    0 0 2.3 2.3 2.3 3.9
    
    Expected output
    Data Set 1:
    7.60
    
  2. Example 2

    Input
    1
    2 3 0
    0 1 2 3
    0 5 6 7
    
    Expected output
    Data Set 1:
    0.00
    
  3. Example 3

    Input
    1
    2 3 0
    1.5 2.0 2.5 3.0
    0.5 1.0 1.5 2.0
    
    Expected output
    Data Set 1:
    2.00
    
  4. Example 4

    Input
    1
    3 0 5
    2.25
    3.10
    0.65
    
    Expected output
    Data Set 1:
    6.00
    
  5. Example 5

    Input
    1
    1 4 3
    0 1.1 2.2 3.3 4.4
    
    Expected output
    Data Set 1:
    3.30
    
  6. Example 6

    Input
    2
    1 2 2
    0 1.0 2.5
    2 3 4
    0 1 1 1
    0 2 2 2
    
    Expected output
    Data Set 1:
    2.50
    
    Data Set 2:
    3.00