codeforces#P1712A. Wonderful Permutation
Wonderful Permutation
Description
You are given a permutation of length and a positive integer .
In one operation you can choose two indices and () and swap with .
Find the minimum number of operations needed to make the sum as small as possible.
A permutation is an array consisting of distinct integers from to in arbitrary order. For example, is a permutation, but is not a permutation ( appears twice in the array) and is also not a permutation ( but there is in the array).
Each test contains multiple test cases. The first line contains the number of test cases (). Description of the test cases follows.
The first line of each test case contains two integers and ().
The second line of each test case contains integers (). It is guaranteed that the given numbers form a permutation of length .
For each test case print one integer — the minimum number of operations needed to make the sum as small as possible.
Input
Each test contains multiple test cases. The first line contains the number of test cases (). Description of the test cases follows.
The first line of each test case contains two integers and ().
The second line of each test case contains integers (). It is guaranteed that the given numbers form a permutation of length .
Output
For each test case print one integer — the minimum number of operations needed to make the sum as small as possible.
Samples
Note
In the first test case, the value of is initially equal to , but the smallest possible value is . You can achieve it by swapping with , resulting in the permutation .
In the second test case, the sum is already as small as possible, so the answer is .