| ||||||||||
| 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 | |||||||||
谁能不能帮我把下面的算法优化一下!!!a[]中存放的是一串数字,然后求解次串数字的最小的子序列和!
例如:
input
0 -6 4 -8 -4 4
output
-14
long dp(long a[],long m)
{
long k;
sum=a[1];
temp=a[1];
min1=a[1];
for(k=2;k<=m;k++)
{
temp=a[k]<(sum+a[k])?a[k]:(sum+a[k]);
min1=min1<temp?min1:temp;
sum=temp;
}
return min1;
}
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator