#C6004. Maximum Complete Book-Cover Pairs

    ID: 49717 Type: Default 1000ms 256MiB

Maximum Complete Book-Cover Pairs

Maximum Complete Book-Cover Pairs

Alice has a collection of books and matching book covers. She wants to pair them up so that each pair consists of one book and one cover. However, to keep the pairs, Alice requires that they form complete sets of exactly K pairs. Given the number of books N, the number of available covers M, and the set size K, help Alice determine the maximum number of book-cover pairs she can keep.

The answer is computed using the formula:

$$\text{result} = \left\lfloor \frac{\min(N, M)}{K} \right\rfloor \times K$$

Note that although a list of book IDs is provided as part of the input, it is not used in the calculation.

inputFormat

The first line of input contains an integer T representing the number of test cases. Each test case consists of two lines:

  1. The first line contains three space-separated integers: N (number of books), M (number of covers), and K (the set size for complete pairs).
  2. The second line contains M space-separated integers representing the book IDs (this list is provided but not used in the calculation).

For example:

3 5 3 2 1 2 3 4 1 4 4 6 5 3 1 2 3 4 6

outputFormat

For each test case, output a single line containing one integer—the maximum number of complete book-cover pairs that can be kept. Each answer should be printed on a new line.## sample

3
5 3 2
1 2 3
4 1 4
4
6 5 3
1 2 3 4 6
2

0 3

</p>