fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. void solve()
  5. {
  6. int n, k;
  7. cin >> n >> k;
  8.  
  9. int val = 1, cnt = 0;
  10.  
  11. for(int i = 0; i < n; i++)
  12. {
  13. int x;
  14. cin >> x;
  15.  
  16. if(x == val)
  17. {
  18. val ++;
  19. cnt ++;
  20. }
  21. }
  22.  
  23. int rem = n - cnt;
  24. int ans = rem/k;
  25.  
  26. if(rem % k != 0)
  27. ans ++;
  28.  
  29. cout << ans << endl;
  30. }
  31.  
  32. int main() {
  33. // your code goes here
  34. int t;
  35. cin >> t;
  36.  
  37. while(t--)
  38. solve();
  39. }
Success #stdin #stdout 0s 5272KB
stdin
4
3 2
1 2 3
3 1
3 1 2
4 2
1 3 2 4
4 2
2 3 1 4
stdout
0
1
1
2