Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

WA 为什么啊? 帮忙看看 谢谢了!!!

Posted by zyf298515649 at 2009-12-23 08:05:40 on Problem 2479
#include<iostream>
#include<fstream>
#include<cmath>
#define Max_Size 100000
using namespace std;

int n,a[Max_Size],bl[Max_Size],br[Max_Size],cl[Max_Size],cr[Max_Size];

int main()
{
     int N,i;
     scanf("%d",&N);
     do
     {
       scanf("%d",&n);
       for (i=0;i<n;++i) scanf("%d",&a[i]);
       bl[0]=cl[0]=a[0];
       br[n-1]=cr[n-1]=a[n-1];
       int i,Max=-2100000000;
       for (i=1;i<n;++i)
       {
         bl[i]=max(bl[i-1],0)+a[i];
         cl[i]=max(bl[i-1],bl[i]);
       }
       for (i=n-2;i>=0;--i)
       {
         br[i]=max(br[i+1],0)+a[i];
         cr[i]=max(br[i+1],br[i]);
       }
       for (i=0;i<n-1;++i) Max=max(Max,(cl[i]+cr[i+1]));
       printf("%d\n",Max);
     }while (--N);
    system ("pause");
    return 0;
}

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator