/ SeriousOJ /

Record Detail

Accepted


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 324.0 KiB
#2 Accepted 19ms 532.0 KiB
#3 Accepted 4ms 532.0 KiB
#4 Accepted 2ms 532.0 KiB
#5 Accepted 2ms 532.0 KiB
#6 Accepted 4ms 696.0 KiB
#7 Accepted 6ms 788.0 KiB
#8 Accepted 6ms 696.0 KiB

Code

#include<bits/stdc++.h>
#define ll long long
#define yes cout << "YES" << endl
#define no cout << "NO" << endl
#define testing cout << "testing ";
#define mod 1000000007
#define optimize() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;

void do_the_honour() {
    int N;
    string S;
    cin >> N >> S;

    int max_consecutive_ones = 0, current_consecutive = 0;

    for (char c : S) {
        if (c == '0') {
            current_consecutive++;
            max_consecutive_ones = max(max_consecutive_ones, current_consecutive);
        } else {
            current_consecutive = 0;
        }
    }

    int zeros_count = count(S.begin(), S.end(), '0');


        cout << max_consecutive_ones << endl;

}

int main() {
    optimize();
    int t = 1;
    cin >> t;
    for(int z = 1; z <= t; z++) {
        do_the_honour();
    }
    return 0;
}

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 14:44:11
Judged At
2024-11-05 14:44:11
Judged By
Score
100
Total Time
19ms
Peak Memory
788.0 KiB