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

可以优化到 n^2

Posted by ksqsf at 2017-10-03 00:04:33 on Problem 3666 and last updated at 2017-10-03 00:09:54
In Reply To:Re:这题我的解题思路 Posted by:mark1989 at 2010-03-20 23:58:08
> 你的dp看上去是 n^3 的,至少你的描述让我觉得是这样的!
可以优化到 n^2:
dp[i][j] = min(dp[i][j-1] - abs(a[i]-b[j-1]), dp[i-1][j]) + abs(a[i]-b[j])

PS:直接写 n^3 确实会 TLE(菜鸟惨痛教训 T_T)

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