1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
| #include <iostream> using namespace std; const int N = 1000000; int T; int n, k; int a[N]; int main() { scanf("%d", &T); while (T--) { scanf("%d%d", &n, &k); for (int i = 0 ; i < n; ++i) scanf("%d", &a[i]); int ans = n; for (int i = 1; i <= 100; ++i) { int cnt = 0; for (int j = 0; j < n;) if (a[j] != i) { ++cnt; j += k; } else { ++j; } ans = min(ans, cnt); } printf("%d\n", ans); } return 0; }
|