CF1814D.Balancing Weapons
省选/NOI-
通过率:0%
时间限制:3.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
You've got a job in a game studio that developed an online shooter, and your first big task is to help to balance weapons. The game has n weapons: the i-th gun has an integer fire rate fi and an integer damage per bullet di. The i-th gun's total firepower is equal to pi=fi⋅di.
You have to modify the values di of some guns in such a way that the new values di will still be integers, and the firepower of all guns will become balanced. Given an integer k, the guns are said to be balanced if 1≤i≤nmaxpi−1≤i≤nminpi≤k.
Since gamers that play your game don't like big changes, you need to change the values di for the minimum possible number of guns. What is the minimum number of guns for which you have to change these values to make the guns balanced?
Note that the new values di must be integers greater than 0.
你进入了一家开发在线射击游戏的工作室工作,你的首个重要任务是协助平衡武器。游戏中共有 n 种武器:第 i 把枪具有整数射速 fi 和每发子弹整数伤害值 di。第 i 把枪的总火力定义为 pi=fi⋅di。
你需要修改某些枪支的 di 值,使得修改后所有 di 仍为整数,且所有枪支的火力值变得“平衡”。给定一个整数 k,当满足 1≤i≤nmaxpi−1≤i≤nminpi≤k 时,称这些枪支是平衡的。
由于本游戏的玩家不喜欢大幅改动,你需要使 di 发生变化的枪支数量尽可能少。问:为使所有枪支达到平衡,最少需要修改多少把枪的 di 值?
注意:修改后的 di 必须为严格大于 0 的整数。
输入格式
The first line contains a single integer t (1≤t≤1000) — the number of test cases.
The first line of each test case contains two integers n and k (2≤n≤3000; 0≤k≤1500) — the number of guns to balance, and the maximum allowed gap between the most and the least powerful weapons.
The second line contains n integers f1,f2,…,fn (1≤fi≤2000), where fi is the fire rate of the i-th gun.
The third line contains n integers d1,d2,…,dn (1≤di≤109), where di is the damage per bullet of the i-th gun.
It's guaranteed that the sum of n over all test cases doesn't exceed 3000.
第一行包含一个整数 t(1≤t≤1000)—— 测试用例的数量。
每个测试用例的第一行包含两个整数 n 和 k(2≤n≤3000;0≤k≤1500)—— 需要平衡的枪支数量,以及最强与最弱武器之间允许的最大火力差距。
第二行包含 n 个整数 f1,f2,…,fn(1≤fi≤2000),其中 fi 表示第 i 支枪的射速。
第三行包含 n 个整数 d1,d2,…,dn(1≤di≤109),其中 di 表示第 i 支枪每发子弹的伤害值。
保证所有测试用例中 n 的总和不超过 3000。
输出格式
For each test case, print the minimum number of guns which damage di you have to change in order to make the guns balanced.
Note that the new values di must be integers greater than 0.
对于每个测试用例,输出为使枪支达到平衡所需更改的、造成伤害值 di 的枪支的最小数量。
注意:新的 di 值必须是大于 0 的整数。
输入输出样例
输入#1
5 4 2 6 3 13 7 1 2 1 2 3 2 100 101 102 100 99 98 5 0 1 12 4 4 3 12 1 3 3 4 2 50 1000 10 1000000000 1 3 5 1 19 11 49 4 72
输出#1
2 3 0 1 2
说明/提示
In the first test case, you can set d1=2 and d2=4. You'll get an array d=[2,4,1,2], and the values of firepower will be p=[12,12,13,14]. The guns are balanced, since 14−12≤2.
In the second test case, you have to change the value di for all three guns. For example, you can set d=[5151,5100,5050].
In the third test case, all guns are already balanced, so you don't have to change anything.
在第一个测试用例中,你可以设置 d1=2 和 d2=4。你将得到数组 d=[2,4,1,2],火力值为 p=[12,12,13,14]。此时枪支是平衡的,因为 14−12≤2。
在第二个测试用例中,你必须修改全部三把枪的 di 值。例如,你可以设置 d=[5151,5100,5050]。
在第三个测试用例中,所有枪支已经处于平衡状态,因此无需进行任何修改。
输入解题思路,AI测评打分。不知道怎么写?