CF1768B 题解
shinzAnmono · · 题解
题意:
给定一个长度为
Solution:
对于一个排列,升序肯定是
我们选择一种
Code:
#include<iostream>
#include<cmath>
int main() {
std::ios::sync_with_stdio(false);
std::cin.tie(nullptr);
int t;
std::cin >> t;
while (t--) {
int n, k;
std::cin >> n >> k;
int arr[n + 1];
for (int i = 1; i <= n; i++) std::cin >> arr[i];
int cur = 0;
for (int i = 1; i <= n; i++)
if (arr[i] == cur + 1) cur++;
std::cout << static_cast<int>(std::ceil(1. * (n - cur) / k)) << "\n";
}
return 0;
}