/ SeriousOJ /

Record Detail

Accepted


  
# Status Time Cost Memory Cost
#1 Accepted 2ms 540.0 KiB
#2 Accepted 7ms 572.0 KiB
#3 Accepted 3ms 576.0 KiB
#4 Accepted 3ms 592.0 KiB
#5 Accepted 3ms 588.0 KiB
#6 Accepted 4ms 732.0 KiB
#7 Accepted 4ms 776.0 KiB
#8 Accepted 3ms 760.0 KiB

Code

/*
 * @author Md. Fahmidur Rahman Nafi
 * @create date 05-11-2024    21:17:29
 */


#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define ll long long
#define ld long double
#define ull unsigned long long
#define lcm(a,b) ((a*b)/__gcd(a,b))
const int MOD = 1000000007;

void solve(){
    int n;
    cin >> n;
    string s;
    cin >> s;

    int zero = count(s.begin(), s.end(), '0');
    int one = count(s.begin(), s.end(), '1');

    if (n == one){
        cout << 0 << endl;
        return;
    } 
    else if (n == zero){
        cout << n << endl;
        return;
    }
    
    int seq = 0;
    int count = 0;
    for (int i = 0; i < n; i++){
        if (s[i] == '0'){
            seq++;
        }
        else{
            seq = 0;
        }
        count = max(seq, count);
    }
    cout << count << endl;
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);

    int t;
    cin >> t;

    while(t--){
        solve();
    }    
}

Information

Submit By
Type
Submission
Problem
P1113 Fliping Game
Contest
Brain Booster #7
Language
C++17 (G++ 13.2.0)
Submit At
2024-11-05 15:17:46
Judged At
2024-11-11 02:31:01
Judged By
Score
100
Total Time
7ms
Peak Memory
776.0 KiB