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

还是递归的DP的好写

Posted by dongshanluo at 2009-06-07 23:47:06 on Problem 3186
dp[i][j]表示只有[i,j]这一连续区间的长度cows时可以得到的最大利润,
显然,当i=j时dp[i][j] = v[i];
i!=j时:
dp[i][j] = max(v[j]+dp[i+1][j]+sum[j]-sum[i],dp[i][j-1]+v[j]+sum[j-1]-sum[i-1])

这个方程的意思是,对于这里的连续区间[i,j],必定有i或者j是先被卖出去的
上述方程整理一下就是
dp[i][j] = max(dp[i+1][j],d[i][j-1]) + sum[j]-sum[i-1];

其中sum[i] = v[1]+v[2]+...v[i];

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