-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path2173a.cpp
More file actions
56 lines (48 loc) · 1.11 KB
/
2173a.cpp
File metadata and controls
56 lines (48 loc) · 1.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#include <bits/stdc++.h>
using namespace std;
int main() {
int t;
cin >> t;
while (t--) {
int n, k;
cin >> n >> k;
string s;
cin >> s;
// int zeroes = 0;
// int sleep = 0;
// for(int i = 0;i<n;i++){
// // cout << s[i] << " ";
// if(s[i] == '0'){
// zeroes++;
// }
// }
// if(zeroes == n ){
// sleep = n;
// }else{
// int index = 0;
// while(index < n){
// if(s[index] == '0'){
// sleep++;
// index++;
// }else{
// index = index + k + 1;
// }
// }
// }
int imp = 0;
int sleep = 0;
for (int i = 0; i < n; i++) {
if (s[i] == '1') {
imp = k;
} else {
if (imp > 0) {
imp--;
} else {
sleep++;
}
}
}
cout << sleep << "\n";
}
return 0;
}