SP350 LANDSCAP - Landscaping

Description

Farmer John is making the difficult transition from raising mountain goats to raising cows. His farm, while ideal for mountain goats, is far too mountainous for cattle and thus needs to be flattened out a bit. Since flattening is an expensive operation, he wants to remove the smallest amount of earth possible. The farm is long and narrow and is described in a sort of two-dimensional profile by a single array of N (1

Input Format

The first line of the input contains integer t representing the number of test cases. Then t test cases follow. Each test case has the following form: - Line 1: Two space-separated integers: N and K - Lines 2..N+1: Each line contains a single integer elevation. Line i+1 contains the elevation for index i.

Output Format

For each test case, output the minimum volume of earth that must be removed to reduce the number of peaks to K.