#C7540. Taxi Route Profit Maximization

    ID: 51423 Type: Default 1000ms 256MiB

Taxi Route Profit Maximization

Taxi Route Profit Maximization

You are given a list of taxi routes, where each route has a certain distance and an associated profit. The task is to assign routes to taxis in order to maximize the overall profit. In each test case, you are provided with an integer n representing the number of available routes, and an integer k representing the number of taxis available. Then, two lists of n integers are provided: one for the distances of each route and one for the corresponding profits.

The objective is to select exactly k routes with the highest profit values. Note that the distances are provided but do not affect the profit selection. The answer for each test case is the sum of the profits of the selected routes.

Input is read from standard input (stdin) and output is written to standard output (stdout).

inputFormat

The first line of input contains an integer t, the number of test cases.

For each test case:

  • The first line contains two space‐separated integers n and k, where n is the number of routes and k is the number of taxis.
  • The second line contains n space-separated integers representing the distances of the routes.
  • The third line contains n space-separated integers representing the profits for the routes.

outputFormat

For each test case, output a single line containing the maximum total profit obtained by selecting k routes with the highest profits.

## sample
2
5 3
10 20 30 40 50
100 200 300 400 500
4 2
15 25 35 45
250 450 150 350
1200

800

</p>