This page is still under construction.

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

Stimulus Package

Time limit5sMemory limit128 MB

Summary
Choose a subset of at most 20 projects within budget B whose combined jobs meet every yearly target, maximizing total infrastructure gain.
Level

Medium5 of 10

Topics
Brute force, Implementation, Greedy, Array
Solved
No attempts yet

Problem

To ease the impact of an economic crisis, a government passes a large stimulus package: rather than waiting for private investors, it funds worthwhile projects that also create jobs. Deciding which projects to fund is hard, because projects differ in how many jobs they create, how much they cost, and how much lasting infrastructure they leave behind. Some projects create jobs right away (like building a bridge), while others create them only in later years (like research).

Each project ii has a cost cic_i, an infrastructure gain gig_i, and a job-creation profile ji,1,ji,2,…,ji,Yj_{i,1}, j_{i,2}, \ldots, j_{i,Y} giving the jobs it creates in each of the next YY years. You are also given a total budget BB and yearly job-creation targets J1,J2,…,JYJ_1, J_2, \ldots, J_Y.

Choose a set SS of projects whose total cost does not exceed BB and whose combined job creation is at least JtJ_t in every year tt (that is, ∑i∈Sji,t≥Jt\sum_{i \in S} j_{i,t} \ge J_t for all tt). Among all such sets, report the maximum possible total infrastructure gain ∑i∈Sgi\sum_{i \in S} g_i. If no set meets every yearly job-creation target within the budget, report that instead.

Input

The first line contains the number KK of data sets. Each data set has the following form:

  • The first line contains three integers nn, YY, and BB: the number of projects n≤20n \le 20, the number of future years 1≤Y≤501 \le Y \le 50, and the total budget 0≤B≤1090 \le B \le 10^9.
  • The next line contains YY integers, the yearly job-creation targets J1,…,JYJ_1, \ldots, J_Y.
  • Each of the following nn lines describes one project with Y+2Y + 2 integers: the job-creation numbers ji,1,…,ji,Yj_{i,1}, \ldots, j_{i,Y}, then the project's cost cic_i, then its infrastructure gain gig_i.

Output

For each data set, print a line Data Set x:, where x is the data set's number (starting from 1). On the next line print either No selection. if no set meets every yearly job-creation target within the budget, or the maximum total infrastructure gain otherwise. Separate consecutive data sets with a blank line.

Examples2

  1. Example 1

    Input
    2
    6 6 100
    2 2 2 2 2 2
    3 0 3 0 3 0 50 100
    1 1 0 0 0 0 20 10
    0 0 1 1 0 0 20 10
    0 0 0 0 1 1 20 10
    0 3 0 3 0 3 55 30
    1 1 1 1 1 1 40 0
    4 2 10
    2 2
    2 1 7 1
    0 1 5 1
    1 1 4 2
    1 0 2 3
    
    Expected output
    Data Set 1:
    30
    
    Data Set 2:
    No selection.
    
  2. Example 2

    Input
    1
    3 2 100
    0 0
    1 1 10 5
    2 0 30 7
    0 2 40 9
    
    Expected output
    Data Set 1:
    21