Can anyone please help me with this problem, what am i missing here…??
Problem Link : CodeChef: Practical coding for everyone
Solution Link: CodeChef: Practical coding for everyone
#include<bits/stdc++.h>
#include
#define ll long long int
using namespace std;
int main(){
ll t; cin>>t;
while(t–){
ll n,k; cin>>n>>k;
string s; cin>>s;
int ans = INT_MIN, tmp = 0, kk = 0;
if(n <= k){
ans = n;
cout<<ans<<endl;
}
else{
// ans = k;
for(int i=0;i<n-k;i++){
int j = i+k;
int l = i-1;
tmp = k;
for(;j<n;j++){
if(s[j] == '1'){
tmp++;
}
else{
break;
}
}
for(;l>=0;l--){
if(s[l] == '1'){
tmp++;
}
else{
break;
}
}
ans = max(ans,tmp);
}
cout<<ans<<endl;
}
}
return 0;
}