Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
我试过 2479的数据弱In Reply To:什么意思呀!我在2479上过了在这个过不了 Posted by:level at 2006-11-15 21:48:50 > #include<iostream.h> > int main() > { > int n; > int *a, *b, *c; > int sum, max; > int i; > while(1) > { > cin>>n; > if(n<=0) return 0; > a = new int[n+1]; > b = new int[n+1]; > c = new int[n+1]; > for(i=1;i<=n;i++) > cin>>a[i]; > max=a[1]; > sum=0; > for (i=1;i<=n;i++) > { > sum+=a[i]; > if (sum < 0) > sum = 0; > else if (sum>max) > max = sum; > c[i] = max; > } > b[1]=a[1]+a[2]; > max=b[1]; > for (i=2; i<=n; i++) > { > b[i]=b[i-1]>c[i-1]?b[i-1]:c[i-1]; > b[i]+=a[i]; > if (b[i]>max) > max = b[i]; > } > /* for(i=1;i<=n;i++) > cout<<c[i]<<' '; > cout<<endl; > for(i=1;i<=n;i++) > cout<<b[i]<<' '; > cout<<endl;*/ > cout<<max<<endl; > delete []a; > delete []b; > delete []c; > } > } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator