未解决

#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;
int a[10100];
int main()
{
    int _case,n;
    int i,j;
    int po,ne,max,ans;
    scanf("%d",&_case);
    for(i=1;i<=_case;i++)
    {
        memset(a,0,sizeof(a));
        scanf("%d",&n);
        for(j=0;j<n;j++)
        scanf("%d",&a[j]);
        ne=0;
        po=0;
        ans=0;
        max=0;
        for(j=0;j<n;j++)
        {
            if(a[j])
            {
                //printf("#%d\n",a[j]);
                if(a[j]>0)max++;
                else
                {
                    ne++;
                    if(ne==2)
                    {
                        max+=2;
                        ne=0;
                    }
                }
            }
            else
            {
                if(max>ans)ans=max;
                ne=0;
                po=0;
                max=0;
            }
            //printf("%d\n",max);
        }
        /*if(n==1&&a[0]==-2)
        {
            printf("Case #%d: -2\n",i);
            continue;
        }*/
        if(max>ans)ans=max;
        if(ans<=0)printf("Case #%d: 0\n",i);
        else printf("Case #%d: %d\n",i,ans);
    }
    return 0;
}

http://acm.hdu.edu.cn/showproblem.php?pid=4561

原文地址:https://www.cnblogs.com/XDJjy/p/3104204.html