fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. #define ll long long
  4.  
  5. int main() {
  6. ll n,x,c;
  7. cin>>n>>x;
  8. int a[n];vector<int>b;
  9. cin>>a[0];int t=1;
  10. for(int i=i;i<n;i++){cin>>a[i];if(a[i]!=a[i-1]){t++;}else{b.push_back(t);t=1;}}
  11. int ans=0;
  12. for(auto i=b.begin();i<b.end();i++){
  13. ans+=(b[distance(b.begin(),i)]+x-1)/x;
  14. }cout<<ans;
  15. return 0;
  16. }
Success #stdin #stdout 0.01s 5296KB
stdin
5 2
1 2 3 1 1
stdout
2