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 |
还是递归的DP的好写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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator