#K93282. Bookstore Revenue Optimization

    ID: 38385 Type: Default 1000ms 256MiB

Bookstore Revenue Optimization

Bookstore Revenue Optimization

Problem Description:

You are given a set of books in a bookstore along with their prices and a number of discount coupons. Each coupon, when applied to a book, discounts its price and therefore the discounted book does not contribute to the revenue. To maximize the revenue, the bookstore should apply the discount coupons to the cheapest books. In other words, if the book prices sorted in non-decreasing order are (a_1 \le a_2 \le \cdots \le a_N), and if the bookstore has (K) discount coupons, then the maximum revenue is given by [ \sum_{i=K+1}^{N} a_i ] where it is assumed that (K \le N); if (K \ge N), the revenue is (0).

The input consists of multiple test cases. For each test case, you will be given the number of books (N) and the number of discount coupons (K), followed by a list of (N) integers representing the prices of the books. Your task is to compute the maximum revenue for each test case when the discount coupons are applied optimally.

inputFormat

Input Format:

The first line contains an integer (T), the number of test cases. Each test case consists of two lines:
1. The first line contains two space-separated integers (N) and (K), where (N) is the number of books and (K) is the number of discount coupons.
2. The second line contains (N) space-separated integers representing the prices of the books.

outputFormat

Output Format:

For each test case, output a single line containing the maximum revenue the bookstore can earn after applying the discount coupons optimally.## sample

3
5 2
4 2 6 8 1
4 1
7 3 5 9
7 3
6 3 8 2 7 1 4
18

21 25

</p>