fork download
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. #define ll int64_t
  4. #define ul unsigned long long int
  5. #define vi vector<int>
  6. #define vl vector<int64_t>
  7. #define all(x) x.begin(),x.end()
  8. #define pb push_back
  9. #define fo(x,a,b) for(int x=a; x<b; x++)
  10. #define rfo(x,a,b) for(int x=a; x>=b; x--)
  11. #define fi first
  12. #define sec second
  13. #define mp make_pair
  14. int sgn(int x) { return x>0 ? 1 : ( x<0 ? -1 : 0); }
  15. typedef pair<int,int> pairs;
  16. double pi = 3.14159265358979323846;
  17. ll mod = 1000000007;
  18.  
  19. int main()
  20. {
  21. #ifdef _DEBUG
  22. freopen("input.txt","r",stdin);
  23. freopen("output.txt","w",stdout);
  24. #endif
  25. ios_base::sync_with_stdio(0);
  26. cin.tie(0);
  27. ll t;
  28. cin>>t;
  29. fo(z,1,t+1)
  30. {
  31. ll n,k;
  32. cin>>n>>k;
  33. vi a(n);
  34. fo(i,0,n) cin>>a[i];
  35. int ans=0,m=k;
  36. fo(i,0,n)
  37. {
  38. if(a[i]==m)
  39. {
  40. m--;
  41. if(m==0) {ans++; m=k;}
  42. }
  43. else m=k;
  44. }
  45. cout<<"Case #"<<z<<": "<<ans<<"\n";
  46. }
  47. return 0;
  48. }
Success #stdin #stdout 0s 4204KB
stdin
3
12 3
1 2 3 7 9 3 2 1 8 3 2 1
4 2
101 100 99 98
9 6
100 7 6 5 4 3 2 1 100
stdout
Case #1: 2
Case #2: 0
Case #3: 1