#abc326g. G - Unlock Achievement
G - Unlock Achievement
Score : points
问题描述
有 项技能,编号为 至 ,以及 项成就,编号为 至 。
每项技能都有一个正整数等级,且所有技能的初始等级均为 。
你可以支付 日元的成本来提升第 项技能的等级 级。你可以根据需要重复此操作任意多次。
当你满足以下条件时,可以获得第 项成就,并得到 日元的奖励:
- 条件:技能 的等级至少为 ,对于所有的 。
请找出通过合理选择提升技能等级的方式所能获得的最大可能总奖励减去所需总成本。
以上为通义千问 qwen-max 翻译,仅供参考。
Problem Statement
There are skills numbered to and achievements numbered to .
Each skill has a positive integer level, and the initial level of every skill is .
You can pay a cost of yen to increase the level of skill by . You can do this as many times as you want.
Achievement is achieved when the following condition is satisfied for every , for which you will receive a reward of yen.
- Condition: The level of skill is at least .
Find the maximum possible total reward obtained minus the total cost required when appropriately choosing how to raise the skill levels.
Constraints
- All input values are integers.
Input
The input is given from Standard Input in the following format:
Output
Print the answer as an integer.
Sample Input 1
2 2
10 20
100 50
3 1
1 4
Sample Output 1
80
There are two skills. It costs yen to raise the level of skill and yen to raise the level of skill .
There are two achievements. Achievement is achieved when skill is at least level and skill is at least level , for which you will receive yen. Achievement is achieved when skill is at least and skill is at least level , for which you will receive yen.
By raising skill to level and skill to level , you will receive the reward of yen for the cost of yen, and the balance is yen.
Sample Input 2
2 2
10 20
100 50
3 2
1 4
Sample Output 2
70
By raising skill to level and skill to level , you will receive the reward of yen for the cost of yen, and the balance is yen.
Sample Input 3
10 10
10922 23173 32300 22555 29525 16786 3135 17046 11245 20310
177874 168698 202247 31339 10336 14825 56835 6497 12440 110702
2 1 4 1 3 4 4 5 1 4
2 3 4 4 5 3 5 5 2 3
2 3 5 1 4 2 2 2 2 5
3 5 5 3 5 2 2 1 5 4
3 1 1 4 4 1 1 5 3 1
1 2 3 2 4 2 4 3 3 1
4 4 4 2 5 1 4 2 2 2
5 3 1 2 3 4 2 5 2 2
5 4 3 4 3 1 5 1 5 4
2 3 2 5 2 3 1 2 2 4
Sample Output 3
66900
update @ 2024/3/10 01:50:22