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 |
可以优化到 n^2In 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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator