CF1706D1.Chopping Carrots (Easy Version)
普及/提高-
通过率:0%
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
This is the easy version of the problem. The only difference between the versions is the constraints on n , k , ai , and the sum of n over all test cases. You can make hacks only if both versions of the problem are solved.
Note the unusual memory limit.
You are given an array of integers a1,a2,…,an of length n , and an integer k .
The cost of an array of integers p1,p2,…,pn of length n is $$$$\max\limits_{1 \le i \le n}\left(\left \lfloor \frac{a_i}{p_i} \right \rfloor \right) - \min\limits_{1 \le i \le n}\left(\left \lfloor \frac{a_i}{p_i} \right \rfloor \right). $$
Here, lfloorfracxyrfloor denotes the integer part of the division of x by y . Find the minimum cost of an array p such that 1lep_ilek for all 1leilen$$.
输入格式
The first line contains a single integer t ( 1≤t≤100 ) — the number of test cases.
The first line of each test case contains two integers n and k ( 1≤n,k≤3000 ).
The second line contains n integers a1,a2,…,an ( 1≤a1≤a2≤…≤an≤3000 ).
It is guaranteed that the sum of n over all test cases does not exceed 3000 .
输出格式
For each test case, print a single integer — the minimum possible cost of an array p satisfying the condition above.
输入输出样例
输入#1
7 5 2 4 5 6 8 11 5 12 4 5 6 8 11 3 1 2 9 15 7 3 2 3 5 5 6 9 10 6 56 54 286 527 1436 2450 2681 3 95 16 340 2241 2 2 1 3
输出#1
2 0 13 1 4 7 0
说明/提示
In the first test case, the optimal array is p=[1,1,1,2,2] . The resulting array of values of ⌊piai⌋ is [4,5,6,4,5] . The cost of p is 1≤i≤nmax(⌊piai⌋)−1≤i≤nmin(⌊piai⌋)=6−4=2 . We can show that there is no array (satisfying the condition from the statement) with a smaller cost.
In the second test case, one of the optimal arrays is p=[12,12,12,12,12] , which results in all ⌊piai⌋ being 0 .
In the third test case, the only possible array is p=[1,1,1] .