/ SeriousOJ /

Record Detail

Wrong Answer


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 320.0 KiB
#2 Wrong Answer 27ms 548.0 KiB
#3 Wrong Answer 7ms 324.0 KiB

Code

#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

int m(int n, const string &s) {
    vector<int> seg;
    int c = 0;

    for (int i = 0; i < n; ++i) {
        if (s[i] == '1') {
            c++;
            while (i < n && s[i] == '1') {
                i++;
            }
            seg.push_back(c);
            c = 0;
        }
    }

    if (seg.empty()) return 0;
    if (seg.size() == 1) return seg[0];

    return *max_element(seg.begin(), seg.end());
}

int main() {
    int t;
    cin >> t;
    while (t--) {
        int n;
        string s;
        cin >> n >> s;
        cout << m(n, s) << endl;
    }
    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:46:46
Judged At
2024-11-11 02:32:32
Judged By
Score
5
Total Time
27ms
Peak Memory
548.0 KiB