Saleh127

cf 1367C

Jun 17th, 2020
135
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.73 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. #define test int t; cin>>t; while (t--)
  4. #define ll long long int
  5. #define Faster ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
  6. int main()
  7. {
  8. Faster
  9. test
  10. {
  11. string a;
  12. ll n,c,d,e,f=0,i,j,k,l;
  13. cin>>n>>k;
  14. cin>>a;
  15. e=k;
  16. for(i=0;i<n;i++)
  17. {
  18. if(a[i]=='1')
  19. {
  20. if(e<k)
  21. {
  22. f--;
  23. }
  24. e=0;
  25. }
  26. else
  27. {
  28. e++;
  29. if(e>k)
  30. {
  31. f++;
  32. e=0;
  33. }
  34. }
  35. }
  36. cout<<f<<endl;
  37. }
  38. return 0;
  39. }
Advertisement
Add Comment
Please, Sign In to add comment