/ SeriousOJ /

Record Detail

Wrong Answer


  
# Status Time Cost Memory Cost
#1 Accepted 0ms 560.0 KiB
#2 Wrong Answer 4ms 656.0 KiB
#3 Wrong Answer 1ms 556.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++;
        }
        else
        {
            max2 = 0;
        }
        if (max1 < max2)
        {
            max1 = max2;
        }
        if (i > 0 && s[i-1] == '1' && s[i] == '0' && max2 > 1)
        {
            max2--;
        }
    }
    return max1;
}

void solve()
{
    int n;
    scanf("%d", &n);
    char s[n+1];
    scanf("%s", s);
    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:25:53
Judged At
2024-11-05 15:25:53
Judged By
Score
5
Total Time
4ms
Peak Memory
656.0 KiB