/ SeriousOJ /

Record Detail

Wrong Answer


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 532.0 KiB
#2 Wrong Answer 21ms 576.0 KiB
#3 Wrong Answer 22ms 532.0 KiB

Code

// Author: Shawn Das Shachin-->(shawn_das)

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define pb push_back
#define mod 1000000007
#define srt(v) sort(v.begin(),v.end())
#define rsrt(v) sort(v.rbegin(),v.rend())
#define OPTIMIZE_IO ios::sync_with_stdio(false); cin.tie(nullptr);

void solve(){
    int n,k;
    cin>>n>>k;
    string str;
    cin>>str;

    int max_count = 0, count = 0,tc=0;
    for (int it : str) {
        if (it == '1') {
            count++;
            tc++;
            max_count = max(max_count, count);
        } else {
            count = 0;
        }
    }

    if(k==0){
        cout<<max_count<<endl;
    }
    else{
        cout<<min(tc,max_count+k)<<endl;
    }

}
int main() {
    OPTIMIZE_IO;
    int t;
    cin>>t;
    while(t--){
        solve();
    }
    return 0;
}

Information

Submit By
Type
Submission
Problem
P1159 Binary String
Contest
Brain Booster #8
Language
C++17 (G++ 13.2.0)
Submit At
2025-02-17 14:57:56
Judged At
2025-02-17 14:57:56
Judged By
Score
0
Total Time
22ms
Peak Memory
576.0 KiB