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

完全背包问题 219ms过,还要优化一下,简单讲一下思路

Posted by 2008022118 at 2009-12-28 18:39:07 on Problem 2063
DD大牛背包九讲中的完全背包O(VN)的解法
for (i 1..N)
for (j cost[i]..Capacity) //是顺序而非逆序
dp[j] = max{dp[j],dp[j-cost[i]] + val[i]}

总资金 为 背包容量,因为利息会成为本金,所以背包容量不断更新(加上一年的利息)。

债券可以看作花费,interest可以看作价值...

219ms的一个简单优化。
预处理 债券的值(因为是1000的倍数,所以 /1000,利息不变),花费除了1000,则容量自然除
1000.
...

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