题库练习 Array Game
← 上一题 下一题 →

A16279 | Array Game

时间限制1s
内存限制256MB
通过 / 提交0/0

题目描述

You are given an array $a$ of $n$ positive integers. In one operation, you must pick some $(i, j)$ such that $1\leq i < j\leq |a|$ and append $|a_i - a_j|$ to the end of the $a$ (i.e. increase $n$ by $1$ and set $a_n$ to $|a_i - a_j|$ ). Your task is to minimize and print the minimum value of $a$ after performing $k$ operations.

输入格式

Each test contains multiple test cases. The first line contains an integer $t$ ( $1 \leq t \leq 1000$ ) — the number of test cases. The description of the test cases follows.

The first line of each test case contains two integers $n$ and $k$ ( $2\le n\le 2\cdot 10^3$ , $1\le k\le 10^9$ ) — the length of the array and the number of operations you should perform.

The second line of each test case contains $n$ integers $a_1, a_2, \ldots, a_n$ ( $1\le a_i\le 10^{18}$ ) — the elements of the array $a$ .

It is guaranteed that the sum of $n^2$ over all test cases does not exceed $4\cdot 10^6$ .

输出格式

For each test case, print a single integer — the smallest possible value of the minimum of array $a$ after performing $k$ operations.

输入输出样例

输入 #1
4
5 2
3 9 7 15 1
4 3
7 4 15 12
6 2
42 47 50 54 62 79
2 1
500000000000000000 1000000000000000000
输出 #1
1
0
3
500000000000000000
C++ 编辑器
输入
输出