#abc322e. E - Product Development

E - Product Development

Score : 475475 points

问题描述

AtCoder Inc. 正计划开发一款产品。该产品具有 KK 个参数,其当前值全为零。该公司目标是将所有参数值提升到至少 PP

共有 NN 个开发计划。执行第 ii 个开发计划(1iN1 \le i \le N)时,对于满足条件 1jK1 \le j \le K 的每个整数 jj,会使得第 jj 个参数的值增加 Ai,jA_{i,j},同时付出成本 CiC_i

任一开发计划不可被执行超过一次。判断该公司是否能够实现其目标,如果可以,找出实现目标所需的最小总成本。

以上为通义千问 qwen-max 翻译,仅供参考。

Problem Statement

AtCoder Inc. is planning to develop a product. The product has KK parameters, whose values are currently all zero. The company aims to raise all parameter values to at least PP.

There are NN development plans. Executing the ii-th development plan (1iN1 \le i \le N) increases the value of the jj-th parameter by Ai,jA_{i,j} for every integer jj such that 1jK1 \le j \le K, at the cost of CiC_i.

A development plan cannot be executed more than once. Determine whether the company can achieve its goal, and if it can, find the minimum total cost required to achieve the goal.

Constraints

  • 1N1001 \le N \le 100
  • 1K,P51 \le K,P \le 5
  • 0Ai,jP(1iN,1jK)0 \le A_{i,j} \le P(1 \le i \le N,1 \le j \le K)
  • 1Ci109(1iN)1 \le C_i \le 10^9(1 \le i \le N)
  • All input values are integers.

Input

The input is given from Standard Input in the following format:

NN KK PP

C1C_1 A1,1A_{1,1} A1,2A_{1,2} \dots A1,KA_{1,K}

C2C_2 A2,1A_{2,1} A2,2A_{2,2} \dots A2,KA_{2,K}

\dots

CNC_N AN,1A_{N,1} AN,2A_{N,2} \dots AN,KA_{N,K}

Output

If AtCoder Inc. can achieve its goal, print the minimum total cost required to achieve the goal; otherwise, print -1.

Sample Input 1

4 3 5
5 3 0 2
3 1 2 3
3 2 4 0
1 0 1 4

Sample Output 1

9

If you execute the first, third, and fourth development plans, each parameter will be 3+2+0=5,0+4+1=5,2+0+4=63+2+0=5,0+4+1=5,2+0+4=6, all of which are at least 55, so the goal is achieved. The total cost in this case is 5+3+1=95 + 3 + 1 = 9.

It is impossible to achieve the goal at a total cost of 88 or less. Thus, the answer is 99.

Sample Input 2

7 3 5
85 1 0 1
37 1 1 0
38 2 0 0
45 0 2 2
67 1 1 0
12 2 2 0
94 2 2 1

Sample Output 2

-1

You cannot achieve the goal no matter what you do. Thus, print -1.

update @ 2024/3/10 01:42:53

}