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

谁能不能帮我把下面的算法优化一下!!!

Posted by ft at 2005-09-22 21:29:30
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:
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