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

Re:为什么我的还是总WA?

Posted by yhm_slxb at 2007-10-11 19:21:31 on Problem 2479
In Reply To:为什么我的还是总WA? Posted by:jackie_wyx at 2007-03-11 12:41:33
> #include <stdio.h>
> 
> main()
> {
>   int t,n,k,i,max,sum;
>   int a[50002],b[50002],c[50002];
>   
>   scanf("%d",&t);
>   for(k=1;k<=t;k++)
>   {
>     scanf("%d",&n);
>     max=0;
>     sum=0;
>     for(i=1;i<=n;i++)
>     {
>       scanf("%d",&a[i]);
>       sum+=a[i];
>       if(sum<0) sum=0;
>       else if(sum>max) max=sum;
>       b[i]=max;
>     }
>     max=0;
>     sum=0;
>     for(i=n;i>=1;i--)
>     {
>       sum+=a[i];
>       if(sum<0) sum=0;
>       else if(sum>max) max=sum;
>       c[i]=max;
>     }
>     max=0;
>     for(i=1;i<n;i++)
>       if(b[i]+c[i+1]>max) max=b[i]+c[i+1];
>     printf("%d\n",max);
>   }
> 
>   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