#K42312. Minimum Possible Value After Subarray Sorting Operations

    ID: 27060 Type: Default 1000ms 256MiB

Minimum Possible Value After Subarray Sorting Operations

Minimum Possible Value After Subarray Sorting Operations

You are given an array of integers A and an integer k. You are allowed to perform at most k operations. In each operation, you may pick a contiguous subarray of A and sort it in non-decreasing order. Your task is to determine the minimum possible value of the final array after performing the operations optimally.

It can be shown that no matter how you perform the operations, the minimum value in the array is always given by \(\min A\). Thus, the answer is simply the minimum element of the array.

inputFormat

The input is given via stdin and has the following format:

T
n1 k1
A1[0] A1[1] ... A1[n1-1]
... 
nT kT
AT[0] AT[1] ... AT[nT-1]

Here, T denotes the number of test cases. For each test case, the first line contains two integers n and k, where n is the number of elements in the array and k is the maximum number of operations allowed. The next line contains n space-separated integers representing the array.

outputFormat

For each test case, output a single line (via stdout) containing the minimum possible value in the array after performing at most k subarray sorting operations.

## sample
1
4 1
3 2 4 5
2

</p>