# 连续最大积

Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 65535/32768 K (Java/Others)
Total Submission(s): 2012    Accepted Submission(s): 633

Problem Description

2 2 0 -2 0 2 2 -2 -2 0

Input

Output

Sample Input
2 2 -2 0 10 2 2 0 -2 0 2 2 -2 -2 0

Sample Output
Case #1: 0 Case #2: 4

#include<stdio.h> int a[50000+100],n; int solve(int s,int e) {     int i,cnt=0,st,ed,flag=1,ans=0;     if(s==n+1) return 0;      for(i=s;i<e;i++)      {

if(a[i]==-2)          {              if(flag)  {flag=0;st=i;}              ed=i;              cnt++;          }      }     if(cnt%2==0) return e-s;     if(ans<ed-s) ans=ed-s;     if(ans<e-st-1) ans=e-st-1;     if(ans<ed-st) ans=ed-st;     return ans; } int main() {     int cas,i,k,ans;     scanf("%d",&cas);     for(k=1;k<=cas;k++)     {         ans=0;         scanf("%d",&n);         for(i=1;i<=n;i++)  scanf("%d",&a[i]);         a[0]=0;         for(i=0;i<=n;)         {             if(a[i]==0)             {                int ii=i+1;                 while(1)                 {                     i++;                     if(i==n+1||a[i]==0)                         {                              int mid=solve(ii,i);                              if(ans<mid)  ans=mid;                               break;                         }                 }             }         }         printf("Case #%d: %d\n",k,ans);     }    return 0; }

#### hdu 4561 水模拟

2014-11-18 10:21:45

#### hdu 4561 模拟小题

2013-07-09 13:38:37

#### hdu 4561

2015-01-29 17:09:45

#### BZOJ 4561 [JLoi2016]圆的异或并

2016-10-22 10:15:53

#### hdu 4561 模拟小题or连续最大积

2017-10-07 18:42:31

#### hdu 4561 模拟题

2017-08-15 19:25:12

#### HDU 5983 Pocket Cube （简单模拟）

2017-02-06 15:49:43

#### HDU 5095 （多项式模拟 ）

2016-08-04 20:21:12

#### [BZOJ4561][JLoi2016]圆的异或并（扫描线+splay）

2017-04-22 18:48:36

HDU 4561 模拟