/ SeriousOJ /

Record Detail

Wrong Answer


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 532.0 KiB
#2 Wrong Answer 20ms 568.0 KiB
#3 Wrong Answer 4ms 532.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 == '1') {
            current_consecutive++;
            max_consecutive_ones = max(max_consecutive_ones, current_consecutive);
        } else {
            current_consecutive = 0;
        }
    }

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

    if (zeros_count == 0) {
        cout << N << endl;
    } else {
        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:41:01
Judged At
2024-11-05 14:41:01
Judged By
Score
5
Total Time
20ms
Peak Memory
568.0 KiB