[Solution] Wonderful Permutation Codeforces Solution
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.
No comments:
Post a Comment