/ SeriousOJ /

Record Detail

Wrong Answer


  
# Status Time Cost Memory Cost
#1 Accepted 0ms 324.0 KiB
#2 Wrong Answer 4ms 320.0 KiB
#3 Wrong Answer 2ms 324.0 KiB

Code

/**
 * ! @Author : - Mohammed Murshedur Rahman
 * ? Date & Time : - 2024-11-05 21:00
 * * BANGLADESH : - SYLHET
 */

#include <stdio.h>
#include <string.h>

int maxValue(char* s, int n)
{
    int max1 = 0;
    int max2 = 0;  

    for (int i = 0; i < n; i++)
    {
        if (s[i] == '1')
        {
            max2++;
            if (max1 < max2)
            {
                max1 = max2;
            }
        }
        else
        {
            max2 = 0;
        }
    }
    return max1;
}

void solve()
{
    int n;
    scanf("%d", &n);
    if (n <= 0)
    {
        printf("0\n");
        return;
    }
    char s[n+1];
    scanf("%s", s);
    s[n] = '\0';
    int max_ones = maxValue(s, n);
    printf("%d\n", max_ones);
}

int main()
{
    int t;
    scanf("%d", &t);

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

Information

Submit By
Type
Submission
Problem
P1113 Fliping Game
Contest
Brain Booster #7
Language
C11 (GCC 13.2.0)
Submit At
2024-11-05 15:48:09
Judged At
2024-11-11 02:29:45
Judged By
Score
5
Total Time
4ms
Peak Memory
324.0 KiB