CF1712A Wonderful Permutation

题目描述

## 题意描述 给你一个 $n$ 的排列 $p_i$ 以及 $k (k \le n)$。 在一次操作中,你可以选择两个编号 $i,j$ 并且交换 $p_i,p_j$。 求最少需要几次操作才能使 $\sum\limits_{i=1}\limits^{k} p_i$ 的值最小。 排列是指由 $n$ 个 $1$ 到 $n$ 的不同整数按任意顺序组成的序列,序列中不能有重复的数字,也不能有大于 $n$ 的数。

输入格式

每个测试点都有多组数据。 第一行一个正整数 $t(1 \le t \le 100)$ 表示数据组数。 对于每一组数据,第一行两个正整数 $n,k(1 \le n,k \le 100)$。 接着一行,一个 $n$ 的排列,表示 $p$ 数组。

输出格式

对于每次询问,一行一个数,表示使得 $\sum\limits_{i=1}\limits^{k}$ 最小所需要的最少操作次数。

说明/提示

In the first test case, the value of $ p_1 + p_2 + \ldots + p_k $ is initially equal to $ 2 $ , but the smallest possible value is $ 1 $ . You can achieve it by swapping $ p_1 $ with $ p_3 $ , resulting in the permutation $ [1, 3, 2] $ . In the second test case, the sum is already as small as possible, so the answer is $ 0 $ .