#abc322e. E - Product Development
E - Product Development
Score : points
问题描述
AtCoder Inc. 正计划开发一款产品。该产品具有 个参数,其当前值全为零。该公司目标是将所有参数值提升到至少 。
共有 个开发计划。执行第 个开发计划()时,对于满足条件 的每个整数 ,会使得第 个参数的值增加 ,同时付出成本 。
任一开发计划不可被执行超过一次。判断该公司是否能够实现其目标,如果可以,找出实现目标所需的最小总成本。
以上为通义千问 qwen-max 翻译,仅供参考。
Problem Statement
AtCoder Inc. is planning to develop a product. The product has parameters, whose values are currently all zero. The company aims to raise all parameter values to at least .
There are development plans. Executing the -th development plan () increases the value of the -th parameter by for every integer such that , at the cost of .
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
- All input values are integers.
Input
The input is given from Standard Input in the following format:
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 , all of which are at least , so the goal is achieved. The total cost in this case is .
It is impossible to achieve the goal at a total cost of or less. Thus, the answer is .
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