/ SeriousOJ /

Record Detail

Accepted


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

Code

#include <bits/stdc++.h>
using namespace std;

#define ll long long int
#define ld long double
#define endl '\n'
#define MIR183_PC ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define yes cout << "YES" << endl
#define no cout << "NO" << endl

void solve() {
    // Your code here
        ll n;
        string s;
        cin>>n>>s;
        vector<ll>zv;
        ll czero=0;
        
        for (ll i=0;i<n;i++){
            if (s[i]=='0'){
                czero++;
            }
            else{
                if(czero>0)zv.push_back(czero);
                czero=0;
            }
        }
        if (czero>0)zv.push_back(czero);
        

        
        sort(zv.rbegin(),zv.rend());
        if(!zv.empty())cout<<zv[0]<<endl;
        else cout<<0<<endl;
}

signed main() {
    MIR183_PC;
    // Always use ll, int may give TLE
    ll tt;
    // tt=1;
    cin >> tt;
    while (tt--) {
        solve();
    }
    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 15:15:00
Judged At
2024-11-05 15:15:00
Judged By
Score
100
Total Time
6ms
Peak Memory
788.0 KiB